Iraqi forces took control of the contested city of Kirkuk on Monday, as two U.S. allies faced off over territory and oil in the wake of the Kurdish region's independence vote last month.

Iraqi forces advanced into the disputed province with the goal of returning to positions they held before 2014, when they fled in the face of an Islamic State push. They recaptured military bases, an oil field and other infrastructure had since been taken over by Kurdish troops. But by the end on the day, they had gone further, taking control of the heart of Kirkuk which had been under Kurdish security control before Islamic State’s rise.

Video showed Iraqi forces lowering Kurdistan’s flag, and raising Iraq’s flag at the city’s provincial council building. Cars packed roads out of Kirkuk on Monday as some residents rushed to leave, others who had been unhappy with Kurdish rule, took to the streets to celebrate.

As well as highlighting the deep rifts in Iraq, the confrontation has also exposed splits among the Kurds themselves. Kurdish factions were divided on whether to allow in Iraqi troops or stand their ground, with some Kurdish fighters, known as peshmerga, ordered to give up their posts.

Washington has trained and equipped the advancing Iraqi troops and the peshmerga Kurdish forces on the other side.

“We don’t like the fact that they’re clashing,” President Trump said at a Rose Garden press conference, adding that the United States had a “very good relationship” with both central government and Kurds.

“We never should have been there,” he said, referring back to the 2003 invasion, “but we’re not taking sides.”

The conflict between Kurdi­stan and the Iraqi government over land and oil is decades old, but a Kurdish referendum for independence last month inflamed the tensions. The Iraqi government, the United States, Turkey and Iran all opposed the vote. For Baghdad, it added urgency to a need to reassert its claims to the province, which has around 10 percent of the country’s oil reserves.

Kurdish forces took full control of the ethnically and religiously mixed city of Kirkuk in 2014 after the Iraqi military fled from large swaths of northern Iraq in the face of an Islamic State push. The Kurds also seized oil fields formerly run by Baghdad that pump hundreds of thousands of barrels of oil per day.

The skirmish between forces that fought together to oust Islamic State militants from their stronghold of Mosul in a brutal operation presented a major distraction for Iraqi forces, which had begun mobilizing westward for operations against the group in the last pockets it controls near the Syrian border.

Lt. Gen. Abdul Ghani al-Asadi, commander of Iraq’s elite counterterrorism forces, said his units were in control of the K-1 military base outside Kirkuk on Monday, the Baba Gurgur oil field and the airport.

Iraqi forces also said they took key road junctions, police stations and military positions.

Some elements of Kurdistan’s Patriotic Union Party, or PUK, whose forces dominate in the area, agreed to withdraw in coordination with Baghdad. But the ruling  Kurdistan Democratic Party, or KDP, opposed a deal.

The general command of Kurdistan’s peshmerga slammed PUK officials for a “major historic betrayal of Kurdistan” by handing over positions, and the militia vowed to fight.

The KDP-affiliated Kurdistan Region Security Council said it destroyed five U.S.-supplied Humvees used in the advance by Iraq’s popular mobilization units, an umbrella group containing Iranian-backed militias that fight as part of Iraq’s security forces.

A video shared online showed six bodies of what appeared to be Kurdish peshmerga soldiers lying by a roadside near Iraqi vehicles. One wore the uniform of a lieutenant colonel.

“This is the result of disobedience of Masoud Barzani,” said the Iraqi fighter who was filming, referring to the leader of Iraqi Kurdistan and the KDP.

As well as having allies on both sides, the flare-up presents another awkward dilemma for the United States.

The Iraqi side is also backed up by Shiite militia forces close to Iran — at a time when the Trump administration has intensified its rhetoric about trying to curb Iranian influence in the region, including increasing sanctions on Iran’s Revolutionary Guard Corps last week.

As the Iraqi flag was raised over Kirkuk’s provincial council building on Monday, both Abu Mahdi al-Mohandes, leader of Iraq’s populization forces

Kurdistan’s security council put out panicked public statements last week as Iraqi forces massed on the edges of the province.

“It’s comical, really,” said a Kurdish official with the KDP, talking about U.S. silence given the presence of Iran-supported militias in the advance.

“If you want to push back Iranian influence, don’t stay quiet,” the official said. “In the Middle East, silence is taken as a sign of weakness.”

But the U.S. Embassy in Baghdad said in a statement that it supports “the peaceful reassertion of federal authority, consistent with the Iraqi constitution, in all disputed areas.”

It called for all parties to “immediately cease military action and restore calm.”

“We are very concerned by reports of violence in Kirkuk and deplore any loss of life,” it added.

The constitution mandated that federal forces should secure disputed territories during the transition period until a referendum could be held on the status of Kirkuk. That was slated to take place in 2007 after a “normalization” process to reverse demographic changes made by former dictator Saddam Hussein, who attempted to assert influence by moving in Arab residents. However, the vote was never held.

“My duty is to work in accordance with the constitution to serve the citizens and protect the unity of the country, which was in danger of partition due to the insistence on holding the referendum,” the prime minister, al-Abadi, said in a statement on Monday.

As Kurdish authorities warned they were about to come under attack last week, Abadi tried to defuse tension, taking to Twitter to assure that Iraqi forces “cannot and will not attack our citizens.”

Iraqi commanders initially dismissed troop movements as routine deployments aimed at securing nearby Hawija, recently recaptured from Islamic State militants.

But Shiite militia leaders close to Iran said they were there to move into the province and presented a list of demands to peshmerga commanders. They said they had set a 48-hour deadline for Kurdish forces to withdraw.

After the deadline expired, Abadi accused the Kurds of deploying militiamen from the Kurdistan Workers’ Party, or PKK, a faction that has waged battles for autonomy in Turkey’s Kurdish region for decades.

Abadi said it amounted to a “declaration of war,” but PKK fighters have been present in the city for several years.

Still in the hands of Kurds on Monday was the Bai Hassan oil field, which is under the control of the KDP and has a capacity of around 200,000 barrels of crude a day. Kurdistan’s regional government is heavily reliant on the field for  its energy needs.

“The orders are to surround K-1 and oil fields and stop and call on the Kurdish forces to retreat,” said a counterterrorism officer who declined to be named because of the sensitivity of the topic as the operation was launched. “There are strict orders to avoid violence.”

But militia commanders took a more combative tone.

Anyone who fights Iraqi forces is “the same as ISIS,” said Karim al-Nuri, a spokesman for Iraq’s mobilization units, referring to the Islamic State. Iraqi state television said that counterterrorism forces, the 9th Division of the Iraqi army and federal police forces had taken “large areas” of the province without a fight. It said popular mobilization units took positions “outside Kirkuk.”

PUK officials on Sunday said that they had made an offer to Baghdad to agree to allow central government troops from the Presidential Guard, who are ethnically Kurdish, into the Kirkuk region. The KDP said it had not agreed to the deal, and hours later a large contingent of Iraqi forces, including counterterrorism troops, police and militiamen advanced.

“We salute and appreciate the courageous position of the peshmerga fighters who refused to fight their brothers in the Iraqi forces,” Qais al-Khazali, leader of the Asaib Ahl al-Haq Shiite militia, backed by Iran, said on Twitter.

Peshmerga fighters who were ordered to withdraw expressed frustration.

“Why did they sell Kirkuk to Iran?” said one fighter interviewed by Iraq’s Beladi television station.

In addition to harboring Kurdish troops, the K-1 military base before the advance was also home to a contingent of U.S.-led coalition forces.

Col. Ryan Dillon, a U.S. military spokesman in Baghdad, said all coalition forces were “safe and secure” but that the tension was distracting from the fight against Islamic State militants.

Karen DeYoung and Alex Horton in Washington contributed to this report.

Read more