(CNN)Two armies funded and trained by the United States have faced off in northern Iraq, in a confrontation that, while seemingly over for now, could have lasting consequences for the future of the country and the broader Middle East.
Kirkuk: A crisis waiting to happen, with consequences for region
The Iraqi Security Forces and pro-Iranian Shia militia took direct control of the oil-rich city of Kirkuk on Monday after being ordered to seize infrastructure that had been under Kurdish control. The forces entered the disputed city and set up checkpoints around its perimeter, while witnesses saw a sole Iraqi flag flying atop the governor's headquarters. The building usually holds both the Kurdish and Iraqi flags.
This confrontation always seemed likely, even inevitable. Not only does Kirkuk sit on one of Iraq's main ethnic and sectarian fault lines; it's also surrounded by some of the country's most valuable oil fields.
The stakes were raised last month when the Kurdish leadership held an independence referendum in the face of international criticism and deep hostility from Baghdad. The decision to extend the vote to disputed areas such as Kirkuk, outside Iraqi Kurdistan's accepted borders, made a bad situation worse.
The city and its surroundings have long been a diverse area comprising Kurds, Arabs and Turkmen. Kurds returned to Kirkuk in huge numbers after the overthrow of Saddam Hussein, and further entrenched their control in 2014 when repelling ISIS advances.
Iraq's Constitutional Court ruled against the referendum, and Iraqi Prime Minister Haider al Abadi called it illegitimate. But the vote went ahead.
Abadi had the option of acquiescing and agreeing to negotiate Iraqi Kurdistan's long-term future, or refusing to accept the challenge it presented to Iraq's integrity. He chose the latter, no doubt under pressure from pro-Iranian Shia militia leaders who have long warned that Kirkuk is a red line.
US efforts to calm the situation have so far come to nought. Before the referendum the State Department urged Kurdish leaders "to accept a serious and sustained dialogue with the central government, facilitated by the United States and United Nations."
The Kurdistan Regional Government ignored the appeal in the belief the referendum would strengthen its hand in negotiations.
Nor has the United States been able to prevail upon Baghdad to exercise restraint. It may be no accident that the advance on Kirkuk came three days after US President Donald Trump's speech on Iran and the designation of Iran's Islamic Revolutionary Guard Corps (IRGC) as a terrorist entity.
The Quds Force, an arm of the IRGC, is a powerful player in Iraq -- training and supplying Shia militia in the fight against ISIS. Its commander, Major General Qassem Suleimani, appears to spend as much time in Iraq as he does in Iran.
The question now is whether the Iraqi army and its allies will be satisfied with their gains or emboldened to roll back the Kurds still further.
It's unclear whether the United States was aware of Iraqi plans to advance on Kirkuk. A statement from the Coalition spokesman in Baghdad on Monday said: "We believe the engagement this morning was a misunderstanding and not deliberate." The coalition "strongly urges all sides to avoid escalatory actions," it said. But by then, Iraqi forces had moved forward across a wide front.
Across the region -- in Iraq, Syria and Turkey -- Washington's preferences and demands have to compete with others in a crowded space, a space where Russia and Iran are sometimes seen as more persistent and determined.
The Kurds are also hobbled by internal rifts, with reports that units loyal to one faction -- the Patriotic Union of Kurdistan -- were among the first to refuse to fight and withdrew from their divisions.
A deal to resolve the current crisis is still possible, but the underlying tensions will not go away. The events of the last decade have persuaded many Kurds, especially the younger generation, that they have no future inside a weak and violent Iraq, and that Baghdad will always cheat the Kurds, one way or another.
Kurdish officials have always expected that post-ISIS larger conflicts would erupt. One senior commander told CNN two years ago that ISIS was no more than an irritant to the Kurds. What they really feared was expansionist Shia militia, well equipped and funded by Iran.
ISIS now faces the loss of the last scraps of territory it holds in Iraq and Syria, to a US-backed force in Raqqa, and to the Syrian army near the Iraqi border.
But its defeat is setting off multiple turf wars. For now, most of those are working out in Iran's favor.