Militants pressing a major offensive in Iraq attacked the country's biggest oil refinery on Wednesday, as the premier scrambled to regain the initiative by sacking security commanders and reaching out to political rivals.
The United States, which is mulling air strikes against the insurgents, said it believed Baghdad's security forces were rallying against the assault, while Iran pledged not to let Shiite shrines in Iraq fall to the Sunni Arab militants leading the charge.
Washington has nevertheless deployed some 275 military personnel to protect its embassy in Baghdad, the first time it has publicly bolstered the mission's security, while other countries have also sought to evacuate nationals and pull diplomats out.
The crisis, which has displaced hundreds of thousands of Iraqis, threatens to carve up the country while the assault on the Baiji oil refinery early Wednesday will likely further spook international oil markets.
From about 4:00 am (0100 GMT), clashes erupted at the refinery complex in Salaheddin province, north of Baghdad, according to a senior official and a refinery employee.
Some stores of oil products caught fire during the assault on the facility, Iraq's biggest refinery.
Officials told AFP a day earlier that the refinery had been shut down and many employees evacuated because, due to the militant offensive that has seen swathes of northern territory slip from government control, several major cities were no longer being supplied with refined oil products.
World oil producers have cautiously watched the unfolding chaos in Iraq, which currently exports around 2.5 million barrels of oil per day, but have thus far stressed that the country's vast crude supplies are safe -- for now.
Watch: Baghdad tense as residents eye insurgency
Oil production unaffected
"The oil infrastructure as well as major production facilities are mostly concentrated in the south with terminals at Basra operating as normal," VTB Capital analyst Andrey Kryuchenkov told AFP.
Kryuchenkov cautioned however: "The situation remains very tense and highly uncertain."
In a bid to see off the militant offensive, Prime Minister Nuri al-Maliki sacked several top security commanders on Tuesday evening, and then stood alongside several of his main rivals in a rare display of unity among the country's fractious political leaders.
Among those fired was the commander for the northern province of Nineveh, the first region to fall in the onslaught, which began on June 9.
Maliki also ordered that one officer face court martial for desertion.
The dismissals came after soldiers and police fled en masse as insurgents on Tuesday last week swept into Nineveh's capital Mosul, a city of two million.
Some abandoned their vehicles and uniforms when faced with the insurgents led by the jihadist Islamic State of Iraq and the Levant (ISIL), but also including loyalists of now-executed dictator Saddam Hussein.
After taking Mosul, militants captured a major chunk of mainly Sunni Arab territory stretching towards the capital.
Also on Tuesday evening, Maliki appeared on television alongside other senior Sunni and Shiite political leaders, including the premier's fierce rival, parliament speaker Osama al-Nujaifi.
The group issued a joint statement pledging continuous dialogue and promising to preserve the country's unity.
And despite the early poor performance of the security forces, Pentagon spokesman Rear Admiral John Kirby said Iraqi troops, with help from Shiite volunteers, were "stiffening their resistance" around Baghdad.
"It certainly appears as if they have the will to defend the capital," he said.
Washington has already deployed an aircraft carrier to the Gulf, but President Barack Obama has insisted a return to combat in Iraq for US soldiers is not on the cards.
Secretary of State John Kerry has, however, said that drone strikes could be used.
Washington has ruled out cooperating militarily with Iran, with whom it has not had diplomatic ties for more than 30 years, but says it remains open to more talks with Tehran over the Iraq crisis.
Iranian President Hassan Rouhani, meanwhile, said Wednesday that the Islamic Republic "will do everything" to protect Shiite shrines in Iraqi cities against the militant assault.
Officials said that militants briefly held parts of the city of Baquba, which at just 60 kilometres (35 miles) from the capital is the closest that fighting has yet come to Baghdad.
The swift advance of militants has sparked international alarm, with UN envoy to Baghdad Nickolay Mladenov warning that the crisis was "life-threatening".
"Iraq faces the biggest threat to its sovereignty and territorial integrity" in years, he told AFP.
The violence has stoked regional tensions, with Iraq accusing neighbouring Saudi Arabia Tuesday of "siding with terrorism" and of being responsible for financing the militants.
Jihadists are said to have killed scores of Iraqi soldiers as they pushed their advance, including in a "horrifying" massacre in Salaheddin province that has drawn international condemnation.
Full coverage: Iraq on the brink