In 2015, as the debate over President Barack Obama’s proposed ­nuclear accord with the Iranian regime roiled the nation, mainstream reporters insisted there were only two choices: the deal or war.

It was understandable. Left-of-center media (that is, most outlets) so adored Obama that one of his aides called them his “echo chamber.” Following the White House line was the dutiful, echo-chamber thing to do — even if it meant ignoring rational alternatives to Obama’s appeasement of Tehran that didn’t entail waging war.

Today, liberals are regurgitating the same claims about the consequences of President Trump’s decision to take out Iranian arch-terrorist Qassem Soleimani. Iran’s threats of retaliation and the statement that it is abandoning restrictions on its nuclear program are evidence, they say, that Team Trump is sleepwalking to war. The only option, in this line of thinking, is returning to the deal.

According to Obama administration alumni and other voices on the left, the deal was keeping Iran’s nuclear ambitions in check, and it was only Trump’s decision to pull out and reimpose economic sanctions that caused the current trouble.

But these are barefaced lies. Obama’s deal didn’t solve the nuclear problem. And Soleimani and his Islamic Revolutionary Guard Corps began to make trouble for America long before Trump’s pullout from the deal.

Obama’s deal, for starters, made it certain that Iran would eventually gain a weapon. It included generous sunset clauses, permitted the regime to inspect its own military facilities and never ­required Tehran to come clean on its past weaponization activities. As bad, the deal ignored Iran’s use of state-sponsored terrorism, run by Soleimani’s outfit, even as it enriched the regime’s coffers.

Sooner or later, the West was going to have to junk the deal and start pressing Iran to abandon both Soleimani’s terror operation and its nuclear quest. Trump chose not to wait. His withdrawal from the deal and reimposition of sanctions hit Iran and Soleimani’s terrorists hard. The despotic ­regime is tottering, and Iran’s ­people again took to the streets to protest, only to be gunned down by IRGC gunmen led by, yes, ­Soleimani.

Rather than seize Obama’s invitation to “get right with the world,” the ayatollahs and Soleimani stepped up their terrorism. They shot down a US drone. They attacked our embassy in Iraq. They tested long-range missiles.

Trump chose to deal with reality as it is. Rather than starting a war, he merely recognized that the ayatollahs have already been waging one against Washington for years. The regime counted on Trump to follow the conventional lie that the only choices are abject appeasement or apocalyptic war.

Trump is no foreign-policy guru, but his instinctive distrust of these so-called experts has served him well. The experts vastly overestimate the regime’s strength in suggesting that the Iranians would try to break out to a nuclear weapon — or that they could inflict more pain on the United States than Washington is prepared to dish out. Just as was the case when Obama folded in the nuclear talks, the West’s hand is far stronger than the pundits who are abusing Trump imagine.

The Soleimani operation makes it clear to Iran’s leaders that the costs of their crimes are now going to be borne by them and not only by their foes or the population that groans under their despotic rule.

Trump understands that playing by the old rules previous administrations respected served the ­interests of a rogue regime.

That is what endangered American lives and made Iran stronger. Despite the bluster from Tehran, it’s likely that the ayatollahs know that they can’t afford a widening conflict in which they will have far more to lose than does the global superpower.

Trump’s political foes need to stop pretending that the president is the one who created this crisis — or that the only choices were appeasement or all-out war. It was high time that someone had the nerve to break the wheel that perpetuated Iran’s power and violence. Whatever happens next, Trump’s resolve to defend American interests is the first step toward undoing the damage that Obama and his media cheerleaders did to American power and prestige.

Jonathan S. Tobin is editor-in-chief of JNS.org. Twitter: @JonathanS_Tobin