Iraqi Prime Minister Nouri al-Maliki has just lost the support of his party, and looks like he will soon be pushed out of office, barring a coup or wildly implausible political turnaround. Maliki's eight years in office have been a disaster for Iraq — his increasingly authoritarian rule and oppression of Iraq's Sunni minority bears no small amount of responsibility for the current Islamic State (ISIS) crisis, which is part of why the US and many others are pushing for him to go.

So maybe now's a good time to remember that the US put him in power in the first place.

An April 2014 piece in The New Yorker, by Dexter Filkins, lays the story out in all of its sordid details. In 2006, the Iraqi civil war seemed uncontrollable, and the Bush administration wanted incumbent Prime Minister Ibrahim al-Jaafari gone. "Can you get rid of Jaafari?", Bush asked US Ambassador to Iraq Zalmay Khalilzad. "Yes," Khalilzad said, "but it will be difficult." Tough as it may have been, Khalilzad eventually got Iraq's parliament to end Jaafari's premiership. But there was not clear candidate to replace him — so the US wanted to find someone to put forward themselves.

According to Filkins, Khalilzad rejected at least one other candidate before turning to the CIA for help in picking Iraq's next PM. The CIA suggested Maliki — a remarkable choice, as it knew almost nothing about him:

Frustrated, Khalilzad turned to the C.I.A. analyst assigned to his office, a fluent Arabic speaker whose job was to know Iraq's leaders. "Can it be that, in this country of thirty million people, the choice of Prime Minister is either Jaafari, who is incompetent, or Ali Adeeb, who is Iranian? Isn't there anyone else?" "I have a name for you," the C.I.A. officer said. "Maliki." Among the Americans, Maliki was largely unknown, though he served on the committee charged with purging the Iraqi government of former members of Saddam Hussein's Baath Party. "He's clean," the C.I.A. officer said; he wasn't corrupt, and he had no apparent connection to terrorist activities. "We haven't got any evidence on him." And, unlike Jaafari, Maliki was "a tough guy," seemingly able to defy the Iranian regime.

Further down in Filkins' piece, we learn just how ignorant US officials were of Maliki. On even basic factual questions, like whether Maliki spoke Farsi, the primary language of Iran, American analysts were confused. On the big questions, like his clear links with American adversaries in Iran, the US was hopelessly in the dark:

A former senior C.I.A. officer, who served in Iraq during the war, told me that U.S. officials were given specific reports about the darkest aspects of Maliki's past. But American diplomats who served in Iraq after the invasion said that they were unaware of any hard evidence that he had engaged in terrorism. "Getting a detailed sketch of Maliki was very difficult," one told me. "All we knew was that he was not a super-duper bad guy, like some of the others." When Maliki met with American officials, he denied being involved in terrorist attacks, and distanced himself from his patrons in Iran. "You can't know what arrogance is until you are an Iraqi Arab forced to take refuge with the Iranians," he told Ryan Crocker, at that time the American Ambassador to Iraq. He said that he had never learned Farsi, and used a translator whenever he met with Iranian officials. But his associate, who said that he was present at meetings with Iranians, told me, "Maliki can speak Farsi very easily." And though Maliki insisted that Hezbollah, the Iranian-sponsored militia and political party, was an object of loathing in the Dawa Party, the associate told me that Maliki was very close to Hezbollah.

The obvious takeaway here is that the Maliki administration, and its sordid legacy, is in large part a creation of the United States. The Bush administration, to its credit, did later figure this out. In 2007, Bush sent Secretary of State Condoleezza Rice to Baghdad to make clear that the US was furious with his performance. "You're a terrible prime minister," she told Maliki, according to the New York Times' Peter Baker. "Without progress and without an agreement, you'll be on your own, hanging from a lamppost."

The second, and only slightly less obvious takeaway, is that invading and trying to rule a country you know precious little about breeds disasters.