In Washington, President Barack Obama called on Iraqi leaders to govern with a more "inclusive agenda" to ensure the country does not descend into civil war. Obama said U.S. troops would not return to combat in Iraq but that he was dispatching up to 300 military advisers to Iraq.
The loss of the Beiji oil refinery, some 250 kilometers (155 miles) north of Baghdad, would be a devastating symbol of the Baghdad government's powerlessness in the face of a determined insurgency hostile to the West. By late Thursday, the two sides held different parts of the refinery, which extends over several square kilometers of desert.
The tenacious fight for the refinery reflected the government's desperation to hold on to a shrinking share of the country and stop the momentum of the Sunni extremists, led by the Islamic State of Iraq and the Levant allied with Sunni tribes and elements of Saddam Hussein's old Baath Party. It also represented al-Maliki's need for a military victory as leaders in both Baghdad and Washington questioned whether he should remain in office.
Shiite politicians familiar with the secretive efforts to remove al-Maliki said two names mentioned as possible replacements are former vice president Adel Abdul-Mahdi, a French-educated economist who is also a Shiite; and Ayad Allawi, a secular Shiite who served as Iraq's first prime minister after Saddam's ouster.
Al-Mahdi belongs to a moderate Shiite party, the Supreme Islamic Iraqi Council, which has close links with Iran.
Also lobbying for the job is Ahmad Chalabi, a Shiite lawmaker who recently joined the Supreme Council and was once a favorite by Washington to lead Iraq a decade ago. Another Shiite from the Supreme Council who is trying to land the job is Bayan Jabr, a former finance and interior minister under al-Maliki's tenure, according to the politicians, who spoke on condition of anonymity because of the sensitivity of the subject.
An Iraqi Shiite lawmaker, Hakim al-Zamili, said he was aware of a meeting in recent days between Iraqi political leaders and U.S. officials over the issue of al-Maliki's future. He said he did not know who attended the meeting.
Al-Zamili belongs to a political bloc loyal to anti-U.S. cleric Muqtada al-Sadr, who has publicly demanded that al-Maliki, in office since 2006, be replaced.
But al-Zamili indicated that he thought efforts to replace al-Maliki should come only after Iraqi security forces beat back the Sunni militants.
"My view is that safeguarding Iraq is now our top priority," al-Zamili said, referring to the loss of a vast chunk of northern Iraq to the militants over the past week. "We will settle the accounts later."
Mohammed al-Khaldi, a top aide to outgoing Sunni speaker of parliament, Osama al-Nujaifi, said: "We have asked the Americans, Britain, Turkey, Saudi Arabia and Iran to work toward denying al-Maliki a new term. The Shiite bloc must find a replacement for him."
Besides the Sunnis, many of al-Maliki's former Kurdish and Shiite allies have been clamoring to deny the prime minister a third term in office, charging that he has excluded them from a narrow decision-making circle of close confidants.
"We wanted him to go but after what happened last week we want it even more," said Mahmoud Othman, a veteran Kurdish politician.
Al-Maliki said this week that the newly elected parliament will meet within days to elect a new president who will in turn ask the leader of the chamber's largest bloc to form a new government. His State of the Law bloc won 92 of the chamber's 328 seats in the April 30 election. He needs a majority of at least 165 lawmakers.
It took al-Maliki several months after the 2010 parliamentary elections to cobble together a government.
The prime minister, who has long faced criticism for not making his government more inclusive, has been adopting conciliatory language in recent days toward Sunnis and Kurds. He said the militant threat affects all Iraqis regardless of their ethnic or religious affiliation and called on Iraqis to drop all "Sunnis and Shiites" talk.
Al-Maliki also made a show of meeting Tuesday with Shiite, Sunni and Kurdish political leaders. A statement issued after the meeting said they agreed to set aside differences and focus on "national priorities."
Despite the warm words, al-Maliki is not known to have made any concrete offers to bridge differences with the Sunnis or the Kurds, who have been at loggerheads with the prime minister over their right to independently export oil from their self-rule region in the north and over territorial claims.
A witness who drove past the Beiji oil facility said the militants manned checkpoints around it and hung their black banners on watchtowers. He spoke on condition of anonymity because he feared reprisals.
One of the militants laying siege to the refinery confirmed by telephone that the facility remained in government hands, saying helicopter gunships slowed the insurgents' advance. The militant identified himself only by his alias, Abu Anas, and there was no way to verify his identity or location.
The army officer in charge of protecting the refinery, Col. Ali al-Qureishi, told state-run Iraqiya television by telephone that the facility remained under his control. He said his forces had killed nearly 100 militants since Tuesday.
A top Iraqi security official, speaking on condition of anonymity, said the refinery's workers were evacuated to nearby villages.
Photos obtained by The Associated Press showed the charred skeletons of destroyed army vehicles by a road that runs past the facility. The photos, taken Thursday morning, also show U.S.-made Humvees captured by the militants flying the black banners and the heavily armed militants manning a checkpoint. In the background, heavy black smoke rises up from the refinery.
The facility's production accounts for just over a quarter of the country's entire refining capacity. It goes strictly toward domestic consumption for gasoline as well as fuel for cooking and power stations.
The gasoline largely goes to northern Iraq, and its closure this week has already caused a shortage there. In Irbil, a city controlled by ethnic Kurds, lines stretched for miles at gas stations as angry motorists shouted at each other.
"Everybody in Mosul and the (northern) Nineva province is coming to Kurdistan to fill up on gas," said a resident of a village near Mosul who gave his name as Mohammed. "And they don't have enough here."
It isn't clear what the insurgents would do if they fully captured Beiji. In Syria, the Islamic State has control of some smaller oil fields, but government air raids have limited their ability to profit from them. Militants have, however, refined oil into usable fuel products at primitive refineries.