Iraqi federal forces seized the contested city of Kirkuk from Kurdish forces almost unopposed yesterday, in a stunning reversal of fortunes for Iraq's Kurds.

The loss of the city and its nearby oilfields is a massive blow to dreams of independence for the Kurds, who last month held an independence referendum in anticipation of entering secession talks with Baghdad.

"We took Kirkuk easily," a lieutenant in the Iraqi federal police emergency response division said by phone. "We are all brothers. There were not problems, some of the Kurdish Peshmerga even took pictures with me," said the 27-year-old, who gave his first name as Moqtader.

The Kurdistan regional government's security council reported that "Iraqi forces and Iranian-backed popular mobilisation forces" attacked in "a major, multi-pronged operation" that deployed "US military equipment, including Abrams tanks and Humvees".

Most Peshmerga forces withdrew from the contested city without fighting, after Baghdad issued the Kurds with an ultimatum to pull back to pre-2014 positions. Long columns of armoured vehicles and pick-up trucks filled with Kurdish fighters withdrew from positions around the city yesterday, jamming roads already crowded with fleeing Kurdish civilians who said they felt abandoned, and feared Shia militias entering the city.

"They cheated us and we've been betrayed," Kawa Mustafa Mohamed shouted from his car as he and his family waited in heavy traffic to leave the city. "I don't know where I'm going now but my father was killed by the Iraqis and I don't want that to happen to my family."

Left behind were disorganised bands of enraged Kurdish gunmen who vowed to defend the city. "Only us volunteers fought, not the Peshmerga," said Hardi Farouk, a 27-year-old in bleached blue jeans clutching an AK-47 rifle in south Kirkuk.

The prospect of a new civil war in the ethnically mixed city is a potential boon for Isil.

Hamish de Bretton-Gordon, a former British army officer now advising the Kurdish Peshmerga, said: "The greatest evil everywhere is Isil. It's the defeat of Islamic State that is key. The trouble is, people in Iraq believe the fight against Isil is over, and that it's focused in Syria, but there are still pockets in Iraq."

Kurdish forces have controlled Kirkuk since 2014, when federal forces abandoned their defences ahead of an Isil advance across northern Iraq.

Since then, the Kurds have exported oil from Kirkuk fields - some 350,00 barrels of oil per day - a critical contribution to their economy since Baghdad stopped budget payments to the region following a dispute over oil revenues in 2015.

In recent weeks, Baghdad stepped up demands for the return of Kirkuk and its oilfields after the Kurds held a disputed referendum on independence.