Just after midnight, in the early hours of Oct. 16, the Iraqis attacked from the points that the Iranian general had identified, and by 8 p.m. — despite fierce resistance by some of the peshmerga — the Iraqis were taking over the city as Kurdish officials and commanders fled. Three peshmerga sources, including two majors, were adamant that they had seen Persian-speaking soldiers wearing the uniforms of the Popular Mobilization Units (PMU) alongside the Iraqis.

Not far from the main Patriotic Union of Kurdistan (PUK) building in Kirkuk, where the meeting took place, a group of American military advisers sat at the sprawling K1 air base. The soldiers would keep their silence as Soleimani and the Iraqis orchestrated the attacks on Kirkuk. One Kurdish official even suggested that there must have been an international agreement to launch such a coordinated strike. The Kurds were in for a big surprise.

The Iranian commander took out a map of the area and spread it out in front of his Kurdish counterparts. “This is our military plan. We will hit you tonight from three points — here, here and here,” the Quds Force officer stated, and then left the meeting with his entourage.

The Kurdish leadership had turned down repeated requests by Soleimani to cancel the Sept. 25 independence referendum , to his indignation. The peshmerga commanders who had fought Saddam Hussein’s army alongside Soleimani and other IRGC commanders in the 1980s knew that the Quds Force commander would take his revenge. After consulting with the top Kurdish leadership, the peshmerga commanders told Eqbalpour that they would not give up Kirkuk.

Around 8 p.m. on Oct. 15, an Iranian general from the powerful Islamic Revolutionary Guard Corps (IRGC) accompanied by Iraqi Commanders Abu Mahdi al-Muhandis and Hadi al-Ameri sat down with the Kurdish commanders in Kirkuk. The IRGC commander, known only by his surname, Eqbalpour, who works closely with Quds Force chief Qasem Soleimani, told the Kurds to give up the city peacefully. “If you resist, we will crush you and you will lose everything,” the general warned the peshmerga commanders, a source with intimate knowledge of the meeting told Al-Monitor.

How the Kurdish peshmerga were defeated so fast is disputed, but lack of ammunition and the longstanding rivalry between the PUK and the Kurdistan Democratic Party (KDP) played an important part. "I fought for four hours and we did not allow the [PMU] to come forward,” said Maj. Nihad, a peshmerga commander in his mid 30s who fought south of the city near the Shiite town of Taza. “We could not continue simply because we had no more ammunition.”

As the Iraqis took control of the city, thousands of Kurdish civilians and peshmerga fled to Erbil and Sulaimaniyah. "They sold us, the [Kurdish] officials sold us,” one peshmerga told Al-Monitor in Qarahanjir, just to the east of Kirkuk, as thousands of desperate and bewildered Kurdish civilians drove their vehicles toward Sulaimaniyah. Kurdish officials could be seen fleeing through the hills in their four-wheel-drive vehicles. Angry crowds along the road near Sulaimaniyah jeered at the officials.

Immediately after their collapse in Kirkuk, KDP and PUK officials accused each other of treason and traded barbs. The KDP accused one wing of the PUK of reaching a secret agreement with Baghdad to sell out the Kurds, while PUK officials said Massoud Barzani, the de facto president of the Kurdistan Region, is reaping what he sowed for his obstinacy in going ahead with the independence referendum against the advice of the Kurds’ closest allies. The two sides also accused each other of looting Kirkuk’s oil and siphoning off millions of dollars in the process.

It appears that Iran succeeded in helping Baghdad squeeze the Kurds and retake all the disputed territories from them. US President Donald Trump said his administration would not side with any party in an internal matter.

While Iran may be buoyant about its success, the Kurdish public is angry and feels betrayed by both Soleimani and the Kurdish leadership. But as the Kurds try to make sense of losing so much after the referendum, Iran may come to regret its decision to humiliate the Kurdish public in the long run. The sense of humiliation is palpable across to the Kurdistan Region. “I have picked up my father’s Kalashnikov to defend my town,” said a young man on Oct. 16, sitting on a hill just outside Kirkuk and clinging to his rusty gun. With tears in his eyes, Garmiyan,18, said that he would not run away and would rather die defending his hometown as he looked down on the road jammed with vehicles fleeing the city.

Anti-Iran sentiment is now growing in the Kurdistan Region, despite how the Kurds have generally seen Iran, a country that they have often turned to in times of need. When Saddam’s regime launched chemical attacks in 1988, the Kurds turned to Iran; again, in 1991, as Saddam’s army attacked Kurdish areas in the aftermath of the Gulf War, many were housed by Iran. By and large, the Kurds see themselves as ethnically closer to Iranians than to Arabs and Turks because of their thousands of years of shared history.

Tehran’s assistance to Baghdad in this episode of Iraq's tumultuous history may thus ultimately hurt Tehran's influence in the Kurdistan Region, while for Iraqi Prime Minister Haider al-Abadi the Shiite commanders may have already become too powerful to contain.

There is no doubt that the Kurdish leadership is guilty of monumental miscalculations by pushing ahead with an ill-timed referendum. But given the reactions to their policies, both Washington and Tehran are likely to come to regret humiliating the Kurdish public in years to come.