Najmaldin Karim, the governor of the Kirkuk governorate, was at his official residence on October 16 when American special forces showed up. They warned him that the Popular Mobilization Forces, an Iraqi Shiite militia controlled by Iran, was on its way to the building. Karim, an ethnic Kurd who had twice been elected governor of this ethnically mixed province, understood that they were not coming to oust him or even to arrest him. They were coming to kill him.

The Americans knew there would be an attack on Kirkuk because their special forces were embedded with the Iraqi army outside the city of Kirkuk and with Kurdish troops, known as peshmerga, within the city. While US soldiers gave Karim the warning that enabled him to escape, the Trump administration did nothing to prevent an attack in which the Iraqi army and the Iranian-commanded militias used American weapons, including Abrams tanks.

The Kurds have long claimed Kirkuk—with its ancient citadel and adjacent oil field—as an integral part of Kurdistan. With no lack of hyperbole, Jalal Talabani, the Kurdish guerrilla leader who became Iraq’s first ever elected president, called the city “Kurdistan’s Jerusalem.” The Kurds first took full control of Kirkuk in 2003 as Saddam Hussein’s army collapsed. At the request of the Bush administration, the Kurds withdrew from the city in exchange for the promise of a referendum that would determine the status of the city and the surrounding province. Although Iraq’s 2005 constitution required the Iraqi government to hold a referendum no later than December 31, 2007, it was never held.

But the Kurds ended up in full control of Kirkuk anyway. At 10 AM on June 10, 2014, the commander of the Twelfth Division of the Iraqi army, Major General Mohammed Khalaf al-Fahdawi, called on Karim. ISIS had just taken Mosul and the general wanted to assure the governor that his division would defend the city. Exactly twenty-four hours later, he was back in Karim’s office asking for civilian clothes and transport out of Kirkuk. A Kurdish brigade was already in the city and, unlike the Iraqi division, it was willing to fight. ISIS never took Kirkuk.

On October 6, Iraqis gathered in Sulaymaniyah, about sixty miles east of Kirkuk, to bury Jalal Talabani. Although Talabani was the Iraqi leader most supportive of American goals in the country, the United States was represented only by its local ambassador. Iran sent its foreign minister, Mohammad Javed Zarif, and the commander of the elite al-Quds Force of the Revolutionary Guards Corps, Qassem Soleimani. Zarif returned to Iran but Soleimani stayed on.

Soleimani is credited with saving Baghdad in July 2014. The US-trained and -equipped Iraqi army had collapsed and ISIS was approaching the capital. Armed with a fatwa from Iraq’s most senior Shia cleric, the Ayatollah Sistani (himself an Iranian), calling on Iraqi Shiites to fight terrorists, Soleimani organized tens of thousands of volunteers to defend the capital and the Shiite holy places. Although Iraq’s constitution expressly prohibits militias outside the Iraqi army, Iraq’s Shiite-controlled parliament legalized the militias under the name Popular Mobilization Forces (or PMF). In the early days of the anti-ISIS campaign, the PMF—still under the effective control of Soleimani—pushed ISIS out of Tikrit, Saddam’s home town. Afterward, they burned Sunni homes, massacred prisoners, and killed civilians thought to have collaborated. Fearful of initiating a new cycle of anger and rebellion among Iraq’s Sunni population, the US prevailed on Iraq’s prime minister, Haider al-Abadi, to keep the PMF out of Mosul. The PMF did, however, participate in the campaigns to take villages around Mosul, with adverse consequences for civilians.

After leaving Talabani’s funeral last month, Soleimani met with PMF commanders and the Iraqi army to plan how Iraq might reassert its authority in Kirkuk. The Iraqis were particularly keen to get rid of Governor Karim. Karim, who had won a measure of support from Kirkuk’s Arab and Turkmen communities, had angered Baghdad by supporting Kurdistan’s recent independence referendum. In retaliation, the Shiite bloc in the Iraqi parliament voted to remove Karim from office, even though Iraq’s high degree of decentralized governance under the country’s constitution does not permit the national parliament to remove an elected governor. Since the Kurdish peshmerga controlled Kirkuk, Karim stayed in office. Soleimani had an additional reason to want Karim gone. Not only was he pro-American, he is an American.

As a young doctor in the 1970s, Najmaldin Karim joined Mullah Mustafa Barzani’s Kurdish insurrection against Iraq’s Baathist regime in which Saddam Hussein was a rising force. When the revolt collapsed, after it was double-crossed by the Shah of Iran and Henry Kissinger, Karim accompanied Barzani into exile in Iran and the Washington suburbs. After Barzani died in 1979, Karim qualified as a neurosurgeon and was on duty at George Washington Hospital on March 30, 1980 when John Hinckley Jr. shot Ronald Reagan and James Brady. He tended to both men in the emergency room and then managed Brady’s care. He briefed Reagan on Brady’s progress—and the Kurds’, though Karim made little headway there. The Reagan administration opposed congressional efforts to cut US aid to Saddam even after he attacked the Kurds with chemical weapons.

Karim discovered, though, that he liked US politics. He became a one-man volunteer lobby for the Kurds—then an almost unknown people in Washington—and made many friends on Capitol Hill, myself included. After the 2003 US invasion of Iraq, Karim put his medical practice on hold to return to his native Kirkuk. He proved so popular as governor that his party’s list in the 2014 Iraqi parliamentary elections won a majority of the Kirkuk MPs.

On October 16, two important PMF commanders raced to reach Najmaldin Karim’s office. Qais al-Khazali commands the Asa’ib Ahl al-Haq, an especially violent component of the militias. In 2007, he helped plan the kidnapping and execution of four US soldiers in Karbala. Abu Mahdi al-Muhandes, the deputy commander of the PMF, was sentenced to death in absentia by a Kuwaiti court for his part in the 1983 bombing of the US embassy there. The US government has considered both men to be terrorists.

The Trump administration, which had been careful to keep the PMF out of ISIS-held Mosul, did nothing to stop these two Iranian-backed terrorists from using American weapons to attack an American ally. But for the action of US soldiers in the area, they would almost certainly have killed another American citizen. After the PMF takeover of Kirkuk, the Pentagon attempted ineffectually to hide its embarrassment by calling the Kurdish-Iraqi fighting a “misunderstanding.” The administration’s complaisant attitude to the Iranian-led action was even more puzzling since it followed Donald Trump’s decision three days earlier to decertify the Iran nuclear deal—justified as a response to Iran’s malign activities in the region, including in Iraq.

Pique toward the Kurds partially explains the administration’s indifference. In February, the Kurdistan Regional Government’s president, Masoud Barzani, wrote a letter to President Trump announcing his intention to hold an independence referendum and explaining the reasons for it. On June 7, the KRG set the date for vote as September 25. The only US reaction came from a State Department spokesman who said the timing was inopportune and mischaracterized the vote as non-binding. (The referendum was binding on the KRG but, as Barzani explained, the Kurds would allow up to two years for negotiations with Baghdad on the divorce before actually declaring independence.)

The Kurds were then caught by surprise when, just two weeks before the vote, Secretary of State Rex Tillerson and the special presidential envoy to Iraq, Brett McGurk, launched a full-scale diplomatic effort to get the Kurds to postpone it. Even that initiative was bungled: a US-sponsored UN Security Council statement directly contradicted private promises made to the Kurds. It was also too late.

Along with former foreign ministers from France and Croatia, I traveled to polling places in various parts of Kurdistan on referendum day. The enthusiasm was palpable. Women came to vote dressed as if they were going to a wedding and many brought their children—usually dressed in traditional Kurdish clothes and carrying Kurdistan flags—so that the children could later say that they were there when their country was born. More than one voter told me that their people had waited for this moment for a century, recalling Sykes-Picot, the Anglo-French secret agreement of 1916 that carved up the region and ultimately led to the Kurds’ involuntary inclusion in the new state of Iraq . There is no doubt that the referendum, which took place without a single violent incident, reflected the long-held desire of almost every Iraqi Kurd for independence. In an election with a strong 72 percent turnout, the people of Kurdistan voted by 93 percent for independence.

Even had he wanted to, it would have been impossible for Masoud Barzani to cancel the referendum days before it took place. But Barzani had no desire to cancel the vote. Already, after ISIS had conquered Mosul and most Iraq’s Sunni areas in June 2014, he was on the verge of declaring independence. As he told me at the time, “Iraq no longer exists. We have a thousand-kilometer border with Daesh [the Islamic State] and thirty kilometers with Iraq.”

When US Secretary of State John Kerry visited in Erbil in July 2014, he asked Barzani to postpone the referendum until the defeat of ISIS. Barzani agreed. Having done as they were asked in 2014, the Kurdish leaders felt that the Americans should respect their decision to go ahead now that ISIS was largely defeated. But Tillerson and McGurk had a new request—to postpone until after the Iraqi parliamentary elections scheduled for the spring of 2018.

The American motives were transparent. The US strategy in Iraq is built around Prime Minister Haider al-Abadi. US diplomats see Abadi as a moderate who reversed the sectarian policies of his predecessor, Nouri al-Maliki. Today, Maliki is blamed for so alienating the Sunnis that he had made possible the rise of ISIS in western Iraq. What is forgotten is that Maliki, too, was once our man in Baghdad, in effect handpicked to be prime minister by Bush’s ambassador to Iraq, Zalmay Khalilzad.

In order for Abadi to prevail against his more extreme Shiite rivals, US diplomats calculated he needed the votes of the Kurdish parliamentarians who hold about a fifth of the seats in the Iraqi parliament. The Kurds, however, were never persuaded that Abadi was much different from his predecessor; indeed, he is a member of the same Shiite religious party that is headed by Maliki. Moreover, Abadi failed to restore Kurdistan’s constitutionally-mandated share of the Iraqi budget, which Maliki had cut. He also successfully blocked the US from supplying the peshmerga with sophisticated weapons like the Abrams tank, even when the Kurds were the only ground force stopping ISIS from taking the entire north of Iraq. To explain why he could not accept the American request to postpone, Barzani told me: “Iraq is not what was on offer in 2003. Iraq is a theocratic, autocratic state. The intention is clear. The faces are different [from Saddam’s time] but the goal is the same. As long as we wait, they get stronger and we get weaker.”

There is now no chance that Kurdish MPs will support a prime minister who ordered an attack on the Kurds. And Abadi has now demonstrated sufficient hard-line credentials with Iraq’s Shiite majority that he may no longer need Kurdish votes to secure a second term.

Trump’s decision to decertify the nuclear deal followed an extensive policy review to come up with an Iran strategy that, in his words, would “counter the regime’s destabilizing activity and support for terrorist proxies in the region.” By supporting Abadi and the Iraqi military, the administration hopes to counter Iran’s regional ambitions. There is a logic to this approach. Saddam’s Iraq checked the spread of the Iranian revolution through the eight-year Iran-Iraq war in the 1980s. An independent Iraq today could block Iran’s access to its ally in Syria, President Bashar al-Assad, and from there to the territory in Lebanon controlled by its proxy, Hezbollah. With this larger strategic picture in mind, sacrificing the Kurds may be an acceptable price to pay—especially as they had declined to follow US advice on the referendum.

There is, however, an obvious flaw in this approach. Saddam Hussein was a Sunni who viewed Iran as the national enemy. In 2003, the United States toppled Saddam, ending ninety years of uninterrupted Sunni rule in Iraq and paving the way for Shiite religious parties to take power through democratic elections. Dawa, the party of Maliki and Abadi, was supported by Iran for decades. One of its coalition partners, the Islamic Supreme Council of Iraq, was founded in Tehran in 1982. Neither Iraq nor Iran has hidden Iran’s involvement in the country. Abadi’s spokesman confirmed Qassem Soleimani’s presence in Iraq, explaining that Iraq had both American and Iranian military advisers. Iran’s army chief of staff, Mohamadi Gulpaigani, was even more direct. According to the Fars news agency, he told a Tehran gathering that “the instructions of the Supreme Leader and the sacrifices of General Soleimani spoiled their plots [US and Israel to divide Iraq], and Kirkuk was liberated.”

As a result of the US invasion, Iraq went from being Iran’s most bitter enemy to its closest ally. Far from blocking Iran’s expanding influence in the region, Iraq has facilitated it. Even as ISIS approached Baghdad in July 2014, the Iraqi government was sending Shiite militiamen to fight for Assad in Syria.

Until very recently, Iran’s access to Syrian government territory was blocked by ISIS-controlled territory in both Iraq and Syria and by Kurdish-controlled territory in northeast Syria and northwest Iraq. When the last ISIS-held towns in the Euphrates valley are cleared, Iran will be able to send military equipment directly through Iraq and Syria to the borders of Israel.

Since 2014, the US has been arming and serving as the air force to Syrian Kurdish fighters known as the People’s Protection Units, or YPG. The YPG now controls about a quarter of Syria’s territory, including the Islamic State’s former self-declared capital of Raqqa. In the rest of Syria, Assad—backed by Iran and Russia—has largely defeated the opposition. In essence, Syria is now divided between a zone controlled by the Assad government allied with Iran and Russia and a large area in the north held by American-supported forces.

The Trump administration is presently brokering a deal between Iraq and the Iraqi Kurds that would place Iraqi troops at Fishkhabour, where two pontoon bridges connect Iraqi Kurdistan with YPG-controlled territory. Because Turkey considers the YPG to be a terrorist organization and the Syrian government aspires to retake its territory, Fishkhabour is the YPG’s only link to the outside world and the only land route for its US military supplies.

The success of Trump’s strategy for containing Iran now depends entirely on an Iraqi government and military that is closely allied with Iran. In a day, the same Iraqi government that already sent forces to fight for Assad can close the Fishkhabour crossing and thus facilitate Assad’s victory against the most substantial portion of Syrian territory not under his control. The Kurdistan Region in Iraq—much diminished in territory and economic resources, and no longer in control of its borders—does not now have the capacity to counter Baghdad or Tehran. If the US objects to Iraq’s pro-Iran policies, the Iraqis always have the option of asking the US to leave. But that is not in Iran’s interest right now. Speaking as an American, the ousted governor of Kirkuk Najmaldin Karim observed: “The US has already spent trillions to accomplish Iran’s objectives in Iraq. As long as we keep doing it, why would Iran want us to leave?”