Why did Donald Trump decide last Friday to temporarily ban immigration from seven Muslim-majority countries and suspend all refugee admissions for 120 days? It all goes back to the war in Iraq.

For the last few years, the establishment conservative answer for why America lost the Iraq War has been: Barack Obama. George W. Bush’s “surge” had belatedly won the war, the argument goes, until Obama withdrew U.S. troops, thus allowing the rise of ISIS. During the 2016 campaign, this storyline allowed the establishment candidates—Jeb Bush, Marco Rubio, Scott Walker, Chris Christie—to blame Iraq on the Democrats and avoid challenging Bush’s decision to launch the war in the first place.

Trump rejected that. He attacked Obama for withdrawing troops, but he also (falsely) boasted that he had opposed the war from the beginning. In so doing, Trump exploited a gap between conservative elites and the conservative grassroots. Conservative elites were loath to condemn the war because they liked Bush and liked the projection of American military force. Ordinary conservatives, on the other hand, were sick of the Arab world and wanted America to kill jihadist terrorists while otherwise having as little to do with the region as possible. (Trump exploited the same divide on Syria. His establishment opponents denounced Russia for intervening there. Trump said, essentially, better them than us). Trump won the nomination, in part, by appealing to those grassroots conservatives who Rich Lowry has called “To Hell With Them Hawks.” Such people, Lowry once argued, “are comfortable using force abroad, but have little patience for a deep entanglement with the Muslim world, which they consider unredeemable.”

For Trump and his supporters, this analysis was appealing because it allowed them to denounce the Iraq war without accepting moral responsibility for the catastrophe it has produced. Bush’s real sin, according to “To Hell With Them Hawks,” was naiveté. He thought Muslims were civilized enough to accept the blessings the U.S. was trying to bring. Turns out, they weren’t. Which is why America should raise high its walls and keep them out. Since we can’t save them, we can at least keep them from infecting us.

This is an old story: In American history, frustrating wars and immigration restrictions have often gone hand in hand. Congress largely cut off Eastern and Southern European immigration in 1921, after Woodrow Wilson’s intervention in World War I failed to remake Europe, and disillusioned Americans turned their backs on the continent instead. In 1952, when Americans were weary of war in Korea, Congress passed the McCarran-Walter Act, which allowed the U.S. to bar leftists from entering the country. If the U.S. couldn’t vanquish communists abroad, it could at least keep them from coming to America’s shores.

Each of these nativist spasms represented an effort to preserve the myth of American purity. Scary forces were rampaging overseas. The U.S. had done its best to stop them but failed. So Americans were now entitled to focus simply on protecting themselves.

Morally, the flaw lies in the assertion of innocence. Refugees are not fleeing Iraq because the U.S. tried to bring the country democracy and prosperity but its benighted people wouldn’t accept it. Refugees are fleeing Iraq because a decade of U.S. sanctions helped impoverish the Iraqi middle class. Then the U.S. invaded, thus breaking the Iraqi state without having anything to replace it with.

Obviously, the U.S. is not responsible for all of Iraq’s traumas. Saddam Hussein deserves much of the blame. But when Iraqis show up at America’s airports, and are held in detention as a result of Trump’s executive order, it’s crucial to recognize that it is partly because of America’s actions that they needed to come here.

In less direct ways, the U.S. has contributed to the suffering in some of the other countries whose immigrants Trump has now temporarily banned. America’s war in Libya helped fracture the state there too. The U.S. has armed and advised the Saudi military campaign that has devastated Yemen.  And throughout the 1980s, the U.S. backed Mohammed Siad Barre, the Somali dictator whose brutal repression helped lay the groundwork for the chaos that has followed his rule.

This doesn’t mean the United States has an obligation to admit every refugee, let alone every immigrant, who wants to enter the U.S. It doesn’t even mean the U.S. has an obligation to admit every refugee from countries like Iraq that we have helped destroy. Of course not. At his most expansive, after all, Barack Obama only proposed admitting 110,000 refugees per year from the entire globe, which is .0003 percent of the U.S. population.

But it does mean that Americans should not view admitting Middle Eastern refugees merely as charity, offered by a virtuous nation to those fleeing a savage part of the world. The United States is implicated in that savagery. And the failure of politicians in both parties to acknowledge that has empowered the Trump supporters who attribute the Middle East’s troubles simply to “Islam.”

“Pride and self-righteousness of powerful nations,” Reinhold Niebuhr once wrote, “are a greater hazard to their success than the machinations of their foes.” And it is pride and self-righteousness that link America’s invasion of Iraq 14 years ago to Trump’s decision to ban Iraqis, and others, from entering the United States today.