Iraqi soldiers and helicopter gunships have battled Sunni militants for a third day over control of Iraq's largest oil refinery.

The loss of the Beiji facility would be a devastating symbol of the Baghdad government's powerlessness in the face of a determined insurgency hostile to the West.

The two sides held different parts of the sprawling site, which extends over several square kilometres of desert.

It accounts for just over a quarter of the country's refining capacity and its output goes towards domestic consumption for things like petrol, cooking oil and fuel for power stations.

The militants, led by the al-Qaida-inspired Islamic State of Iraq and the Levant, clearly hope to get millions of dollars from operating the refinery - as they did for a while after seizing oil fields in neighbouring Syria.

More broadly, however, capturing the facility could weaken Prime Minister Nouri al-Maliki's hold on power by calling into question his ability to stop the militants' advance anywhere in Iraq.

In the strongest sign yet of US doubts about Iraq's stability, the administration of Barack Obama is weighing whether to press the Shiite prime minister to step down in a last-ditch effort to prevent disgruntled Sunnis from igniting a civil war.

The fighting at Beiji, some 250 kilometres (155 miles) north of Baghdad, comes as Iraq has asked the US for airstrikes targeting the militants.

While Mr Obama has not fully ruled out the possibility, such action is not considered likely to happen soon because intelligence agencies have been unable to identify clear targets on the ground, officials said.

A witness who drove past the facility said the militants manned checkpoints around it and hung their black banners on watchtowers.

One of the militants laying siege to the refinery confirmed by telephone that it remained in government hands, saying helicopter gunships had slowed the insurgents' advance. The militant identified himself only by his alias, Abu Anas.

A top Iraqi security official also said the government still held the facility but that the refinery's wokers were evacuated to nearby villages.

The army officer in charge of protecting the refinery, Colonel Ali al-Qureishi, told state-run Iraqiya television the facility remained under his control. He said his forces had killed nearly 100 militants since Tuesday.

Photos showed the charred skeletons of destroyed army vehicles sitting by a road that runs past the facility. They also show US-made Humvees captured by the militants flying the black banners and heavily armed militants manning a checkpoint.

In the background, there is heavy black smoke rising up from the refinery.

Any lengthy outage at Beiji risks long lines at the petrol pump and electricity shortages, adding to the chaos already facing Iraq. It produces around 300,000 barrels per day.

Fuel produced at the refinery largely goes to northern Iraq and its closure has caused a shortage in the region. In Iribil in Iraq's Kurdish region, queues stretched for miles for open gas stations as angry motorists shouted at each other.

Some bought fuel to power generators as electricity went out in some areas held by the Islamic State.

"Everybody in Mosul and the (northern) Nineva province is coming to Kurdistan to fill up on gas," said Mohammed, a resident of a village near Mosul. "And they don't have enough here."

The assault on the refinery also has affected global petrol prices, as the US national average price reached the highest for this time of year since 2008, the year fuel hit its all-time high in America.

The campaign by the Islamic State militants has raised the spectre of the sectarian warfare that nearly tore the country apart in 2006 and 2007, with the popular mobilisation to fight the insurgents taking an increasingly sectarian slant, particularly after Iraq's top Shiite cleric made a call to arms on Friday.

The Islamic State has vowed to march to Baghdad and the Shiite holy cities of Karbala and Najaf, home to some of the sect's most revered shrines, in the worst threat to Iraq's stability since US troops left in late 2011.

The militants also have tried to capture Samarra, a city north of Baghdad and home to another major Shiite shrine.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.