Updated

Gunmen stormed Iraq's largest oil refinery and bombed the facility Saturday, forcing operations to shut down at a time when Iraqis are already suffering through electricity shortages and lines at the gas pump.

The attack north of Baghdad casts doubt on the Iraqi government's ability to protect its vital infrastructure and could shake already nervous international investors. If not fixed swiftly, the shutdown will likely further fuel anger over a lack of public services that led to violent nationwide protests last week.

"It probably couldn't have come at a worse time for (Prime Minister) al-Maliki and his government," said Raad Al-Kadiri, an energy analyst with the Washington-based PXE Energy.

The Beiji oil refinery accounts for a little more than a quarter of the country's entire refining capacity — all of which goes toward domestic consumption for things like gasoline, cooking oil and fuel for power stations.

One of the key demands during protests Friday in which at least 14 people were killed was that Prime Minister Nouri al-Maliki's government improve the country's electricity output — some Iraqis get only a few hours a day.

A lengthy outage would force Iraq, already grappling with a $13 billion budget deficit, to purchase more refined products on the open market. Analysts said storage facilities in Dora and Basra will be able to compensate for at least some of the immediate shortfall in production.

The sophisticated attack against the Beiji facility, located about 155 miles (250 kilometers) north of Baghdad in the heart of what used to be an al-Qaida infested area, was carried out in the dead of night.

Assailants carrying pistols fitted with silencers attacked the guards at about 3:30 a.m. and planted bombs near some benzene and kerosene production units, said the spokesman for Salahuddin province, Mohammed al-Asi.

One guard was shot dead and another wounded, al-Asi said. Smoke could be seen billowing from fields around the sprawling facility where fires raged for hours.

Dr. Abdul Jabbar al-Halfi, a professor at Basra University's oil engineering department and frequent visitor to the Beiji refinery, pointed out that visitors to Beiji need a special badge to even get within a mile (2 kilometers) of the facility and suggested it might have been an inside job.

There was no immediate claim of responsibility, although insurgents have targeted oil facilities in the past.

The attackers knocked out the installation's North Refinery, which handles about 150,000 barrels a day; the refinery's other section, called the Salahuddin Refinery, is under renovation and was not affected.

Iraqi Oil Ministry spokesman Assem Jihad said an investigation would be launched.

Technicians currently repairing the refinery estimated it would be back online later this week, the province spokesman Al-Asi said. Authorities dispatched about 45 soldiers to temporarily protect the facility.

But the complicated attack on one of the most vital installations in the country raises questions about the government's ability to protect its own infrastructure.

At the height of the insurgency from 2004 to late 2007, the Beiji refinery was under the control of Sunni militants who used to siphon off crude and petroleum products to finance their operations.

Iraq has the world's third-largest known oil reserves with an estimated 115 billion barrels, but its production is far below its potential due to decades of war, U.N. sanctions, lack of foreign investment and insurgent attacks.

Al-Maliki's government has tried to drum up international investment through three energy auctions. While those have focused on developing oil fields as opposed to refineries, any uptick in violence against oil-related installations could rattle investors.

Most oil companies doing business in Iraq, even in the relatively stable southern region, spend huge sums of money on security, including armed guards, armored vehicles.

"The oil industry and investors, while they're there in great numbers, already have one eye toward security," al-Kadiri said.

Hours after the Beiji facility was attacked, a fire in a storage unit at the small refinery in Samawa, a city on the Euphrates River about 230 miles (370 kilometers) southeast of Baghdad, knocked the facility offline, according to a local official.

The official, who spoke on condition of anonymity because he was not authorized to release information, said the fire was caused by a technical failure, not sabotage. He wouldn't say when work would resume at the plant, which has a production capacity of 30,000 barrels per day.

Iraq's current nationwide refining capacity stands at just more than 500,000 barrels per day. The country's three main oil refineries — Dora, Shuaiba and Beiji — now process around 350,000 barrels per day, roughly half of their prewar capacity.

Last year, Baghdad invited investors to help build four oil refineries at an estimated cost of $23 billion that would more than double the country's current refining capacity.

__

Associated Press writers Sinan Salaheddin and Mazin Yahya contributed to this report.