Iraq's prime minister pulled a shock legal stunt Monday in his increasingly desperate bid to cling to power, dragging Iraq into a tense political endgame even as fighting raged in the north.
A defiant Nuri al-Maliki went on state television on the stroke of midnight to announce he was challenging President Fuad Masum in court for failing to nominate him as prime minister.
The move drew a sharp warning from the United States for Maliki not to worsen the chaos caused by a two-month-old jihadist offensive that has brought Iraq to the brink of breakup.
But Iraq's federal court, the same that lifted the two-term cap for Maliki last year, swiftly ruled in his favour again.
"The federal court announces its decision confirming that State of Law is the largest bloc in parliament," Iraqiya TV reported.
A constitutional tussle on how to define the largest bloc in parliament had been the main technical obstacle in Maliki's way since his coalition's comfortable electoral victory in April.
It remained unclear however whether Masum would comply and hand Maliki a chance to form a government or whether the president would explore other options.
Speaking before the court decision was announced, US Secretary of State John Kerry gave Masum his unequivocal support and said: "Our hope is that Mr. Maliki will not stir those waters."
It had been thought Maliki was simply trying to gain leverage to impose his preferred replacement but the court ruling suggested the 64-year-old was prepared to go all the way to save his job.
Moments before he spoke on television, special forces, soldiers and police deployed across Baghdad, especially around the Green Zone district housing the country's key institutions.
Several of the capital's main thoroughfares and bridges were closed to traffic and on Monday morning unusual numbers of security personnel, uniformed and plain-clothed, remained deployed across the city.
In his brief address, Maliki said Iraq was facing a "dangerous" situation and urged "the sons of Iraq" to be on alert.
Observers argue that Maliki is too isolated to remain in power by force but security officials told AFP the security set-up was akin to state of emergency measures.
Maliki had pledged in a 2011 AFP interview he would not seek a third term but he has since changed his mind despite losing the support of nearly all his erstwhile allies: the United States, Iran, and even his Dawa party.
Masum is a Kurd and relations between Baghdad and the autonomous Kurdish region in northern Iraq have been strained of late.
The Kurds have long complained that the federal government was not sending them their 17 percent share of federal oil resources.
Kurdish peshmerga fighters then seized long-coveted areas over which they were in dispute with Baghdad, including the oil-rich Kirkuk region, when routed federal forces retreated in the face of the jihadist onslaught two months ago.
That prompted Maliki to accuse the Kurdistan Regional Government of siding with the Islamic State (IS) group and the "caliphate" it declared in late June over parts of Iraq and Syria.
Cash-strapped Kurdistan's troops initially fared better than Baghdad's but over the past week jihadists made spectacular gains, seizing the country's largest dam and advancing within striking distance of the Kurdish capital.
That was one of the reasons that prompted US President Barack Obama to announce on Thursday he was sending warplanes back over the skies of Iraq for the first time since the last US troops withdrew in 2011.
His other justification was the risk of an impending genocide against the Yazidi minority, many of whose people had been stranded on a mountain following an Islamic State attack.
Three days of strikes by US jets and drones appeared to make an impact on both fronts, raising hopes that US intervention could turn the tide on two months of jihadist expansion.
"The peshmerga have liberated Makhmur and Gwer," peshmerga spokesman Halgord Hekmat told AFP, adding that "US aerial support helped".
Meanwhile, officials said 20,000 mostly Yazidi civilians who had been trapped on Mount Sinjar since jihadists overran their hub of Sinjar a week ago had managed to escape.
They were escorted through Syria and back into Iraqi Kurdistan by Kurdish forces and added to the more than 200,000 displaced persons who have already entered the autonomous region since August 3, according to figures provided by several aid groups.
Only hours before Maliki spoke on television, French Foreign Minister Laurent Fabius was in Iraq to supervise the delivery of French aid.
Britain has also joined a humanitarian effort, which Obama said was aimed at averting an impending genocide by sending in transport planes to drop emergency supplies to Sinjaris.