Of the three immense embarrassments that befell the Trump presidency in mid-July, two were the fault of Trump’s aides and allies. The third was entirely his own doing. The difference is telling, and it’s critical that we understand it.

The first two embarrassments — Donald Trump Jr.’s Russia meeting and Congress’s failure to repeal Obamacare — may teach us something about the nature of the Trump administration and the Republican Party in the Age of Trump. At the very least, they provide endless fodder for late-night television comics.

The third — Trump’s recertification of the “disastrous” Iran nuclear deal that he’d sworn he’d cancel — is a different matter. He’d already recertified it once, in April. He didn’t want to do it again just three months later, as required by Congress. Only under enormous pressure from his national security team — Secretary of Defense James Mattis, Secretary of State Rex Tillerson, National Security Adviser H.R. McMaster and Chairman of the Joint Chiefs of Staff Joseph Dunford — did he grudgingly, angrily back down.

The episode carries sobering lessons about the fragility of global security in an age of right-wing populism, and about the changing role of the military in a democracy. We’re living in a time when populations are falling under the spell of hyper-nationalist ideologues and fantasists; when liberal democracy is on the defensive, groping in the dark, unable to inspire; when generals and spymasters are becoming the unlikely, last-ditch champions of prudence, reason and fact-based realism.

To see how far reality has retreated before the relentless advance of fantasy in our public discourse, look no further than the arguments marshaled against Trump’s recertification of the Iran nuclear deal. Opponents claim that the Iran agreement, while technically focused on halting Iran’s nuclear weapons program, was implicitly meant to go further. It was supposed to rein in Iran’s excesses and reform its troublesome role as a regional troublemaker, human-rights abuser and sponsor of terrorism. The opponents say, as neoconservative defense analyst Reuel Marc Gerecht suggested in a New York Times opinion essay this week, that as long as Iran is still committing human rights abuses, the president shouldn’t certify its nuclear compliance.

There’s a bizarre irony here: Back when the agreement was being negotiated, critics said it was inadequate because it didn’t demand broader reforms of Iran’s behavior. Besides, they argued, the deal’s actual contents, its technical rules limiting Iranian nuclear development, were full of holes, unenforceable and certain to be violated, not to mention time-limited, set to expire in a decade or two.

And yet, now that the deal is in effect — and being observed, inspectors are finding — the critics complain that Iran isn’t really in compliance because it’s not honoring those implicit, broader goals. Yes, the goals they just got through complaining were fatally missing from the deal.

To be fair, the critics are half right. Iran is still an abuser, a regional troublemaker and a sponsor of terrorism. In some ways it’s worse than ever. So what went wrong? Why isn’t this peace agreement bringing peace? Answer: because it wasn’t intended to bring peace. It was intended to make the continuing conflicts between Iran and its neighbors less devastating.

Couldn’t the negotiators have demanded reform of Iran’s chronic misbehavior as part of the agreement? Here’s another irony: The point of urgently pursuing nuclear negotiations in the first place was precisely that Iran wasn’t going to change its behavior. It seemed important to ensure that such a dangerous player not get its hands on a nuclear weapon and become that much more dangerous. Remember, this was Israeli Prime Minister Benjamin Netanyahu’s message when he addressed the United Nations in 2012 with that silly cartoon drawing of a bomb. Look how dangerous a player Iran is, he said. Imagine if it had a nuke. It must be prevented from getting one.

And that’s what the negotiators — representing a broad global consensus led by America, Great Britain, France, Germany, Russia and even China — set out to do. If they didn’t go the next step and seek broader Iranian reforms, that’s because those reforms weren’t achievable. Demanding them would have sunk the whole effort, leaving Iran as mean as ever and weeks away from a bomb.

The fact is, negotiations can make a party give up something, even something of value, if the price is right. But negotiations can’t get a believer to stop believing. Countries don’t give up their identities voluntarily, only by force. And Iran’s regional troublemaking is part of its core identity as the champion of Shi’a Islam. It’s ruled by a millennial religious sect that believes it’s divinely ordained to pursue a particular kind of regional order. No means are illegitimate in pursuing God’s will.

It’s not that brute force intervention didn’t have its advocates. But the case for force had a hard time gaining traction. We had tried that just a few years earlier in Iraq, where we toppled the Saddam Hussein regime. That action had unintentionally eliminated the Iranian regime’s most serious enemy, leaving Iran free to expand its regional ambitions. Making things worse, America tried to impose something like democracy on post-Saddam Iraq. That predictably empowered Iraq’s Shi’ite majority, which has moved steadily ever since into the orbit of Iran, the Shi’ite citadel next door. In the end, America’s Iraq invasion turned Iran into a regional superpower.

There’s been talk in Washington and especially Jerusalem of a surgical military strike, stopping short of regime change, to knock out Iran’s nuclear facilities. President Obama promised Netanyahu that America would keep that option on the table in case talks failed. But it was truly a last resort, and its effectiveness would be limited. The military and intelligence establishments in both countries made clear that a strike would only set Iran back three to five years, and would drive Iran to rebuild its nuclear capacity afterwards with greater determination than ever — and with greater international legitimacy, since it could now argue that it had just been attacked by genuine nuclear powers and needed nukes for self-defense. What’s more, the benefits of an attack, rather than “sunsetting” and requiring a reboot in 15 years, like Obama’s 2015 deal, would evaporate in five years with no chance of renewal.

Netanyahu actually tried in 2010 and again in 2011 to prepare an Israeli air strike regardless. He was blocked, however, by furious opposition from the heads of Israel’s military and intelligence agencies.

Here’s where the parallel between Israel in 2010 and America in 2017 becomes inescapable. In both cases, a government headed by a charismatic leader with right-wing, populist, hyper-nationalist leanings and backing from religious millennialists is intent on countering Iran with a recklessly confrontational tactic that would almost certainly backfire militarily and outrage international allies. In both cases, the political opposition is essentially paralyzed, isolated, hoping for a diplomatic solution but unable to make its case to the public, partly because the opposition’s base still hopes for an outcome of peace and reconciliation — in Israel this is more true on the Palestinian issue than Iran — that the general public doesn’t find credible.

And in both countries it falls to the security services to make the case that the left can’t — namely, that diplomacy is a better option than military force. It is better not because diplomacy will win the hearts of the other side — it won’t — but because diplomacy will get you more of what you want.

Given all we know about the pros and cons of the Iran deal and its alternatives, the question we’re left with is why so many smart people on both sides of the Atlantic have become so entrenched in illogical, borderline nonsensical opposition. The answer probably lies in the perfect storm of political, societal and psychological trends that have combined to drive the surge of populist illiberalism that’s threatening democracy throughout the West, most dramatically in America and Israel. There’s an economic stagnation that leaves the middle class wounded, cynical about the value of careful political discourse and thoroughly tired of nuance. There’s a dramatic rise in religious fundamentalism and end-time millennialism that’s sweeping the globe, from Muslim Iran and Gaza to Christian Alabama and Texas to Hindu Gujarat and Ayodhya to Jewish Yitzhar and Bat Ayin.

There’s an explosive surge in popularity of absolutist social thought that views public policy as a conflict between good and evil and thus casts a shadow over compromise and all the various practices that depend on it, from legislating to diplomacy to academic debate. And there’s the triumphant march of technology that compresses human thought into instant messages that leave no time for contemplation and no patience beyond 140 characters. As the wise cartoon possum Pogo Swamp used to say: we have met the enemy, and he is us.