The Iranian regime faces the most serious popular challenge to its tyranny in 40 years. Sparked by a 50 percent hike in fuel prices last month, the uprising has spread to the whole country. Security forces have killed hundreds of protesters, and at one point they were even forced to shut down the internet — a sign that the ayatollahs feared for the survival of their regime.

So it’s worth asking: Did our ­experts see this coming?

Nope: Most were too busy blasting President Trump. The prestige press and Twitterati spent the last few years railing against the president for trashing the nuclear deal and ratcheting up sanctions — actions that had supposedly sent the Iranian people rallying around the flag.

Writing in February, New York Times Tehran correspondent Thomas Erdbrink described a ­nation standing behind its government. “Braving a drenching rain,” he wrote, “Iranians came out in droves … to march up Revolution Street to the capital’s Freedom Monument … for a huge state-backed rally commemorating the 40th anniversary of the ­Islamic Revolution.”

Erdbrink also described Iranians parading effigies of Trump. But a reader would get little sense of a brutal regime’s internal crisis of legitimacy that would explode a few months later.

You could hear a similar story on public radio, where PRI’s popular show “The Conversation” warned this summer that Trump’s sanctions would prove catastrophic. The president’s hard measures, the show suggested, would yield “the classic ‘rally-around-the-flag’ effect. Iranians are critical of their government’s economic policies, but they also blame Trump for the hardships resulting from sanctions.”

The same conventional wisdom traveled all the way down the journalistic totem pole, with Newsweek’s David Brennan predicting last month that “Trump’s treatment of Iran will ensure America remains the ‘Great ­Satan’ for years to come.”

The very same ideas, often ­expressed in the very same words, emanated from Washington’s bien pensants at an alarming rate. Colum Lynch, Foreign Policy’s senior diplomatic correspondent, touted an academic poll in October that found conclusive evidence supposedly showing that Trump’s sanctions had “increased Iranian hostility toward the United States and boosted the popularity of Iranian hard-liners.”

Writing in the same publication a year earlier, Philip Gordon of the Council on Foreign Relations and Robert Malley, a former Team Obama adviser, said the same thing only with more scorn. “In Trump’s vision, sanctions are a quasi-magical, multipurpose tool,” they wrote, which “might even lead the Iranian people, facing a collapsing economy, to rise up and sweep aside the Islamic regime. That’s an impressive wish-list. It’s also utterly implausible.”

Holly Dagres agreed in The Atlantic, judging Trump’s policy to have produced “meager results” and noting that “the heavy US pressure on Tehran in recent months has led to a rally-around-the-flag effect as Iranians push back against what many view as a Western imperialism.”

Dror Michman, a Brookings ­Institution visiting fellow, concurred. Trump’s sanctions, he wrote, “will also have a huge ­impact on the Iranian president and will strengthen the radicals in Iran who always claimed that the West could not be trusted.”

The unimprovably named Marik von Rennenkampf, an analyst appointed by Team Obama to the Pentagon, was even less subtle. “Bellicose threats and confrontation lead to a ‘rally-round-the-flag’ effect,” he wrote in July in The Hill, “where the Iranian population supports the government in power, regardless of how unpopular or authoritarian it may be.”

As they say in Foggy Bottom: Oopsies.

The problem here isn’t that so many experts were so wrong — even the best thinkers can sometimes miss the mark. The problem is that all of our experts were wrong in exactly the same way, for precisely the same reason.

Blinded by their disdain for Trump, they could credit no narrative that didn’t feature the president as the ultimate bumbler. Otherwise, they’d have had to accept two rather obvious points: that the billions paid by Team Obama kept the despised mullahs afloat; and that Trump imposing strict sanctions ­deprived the mullahs of the ­resources they need to keep ­oppressing the Iranian people.

So much was clear to anyone who actually bothered looking at Iran soberly. Sadly, this excludes more or less our entire liberal foreign policy establishment, most of academia and the media.

It’s a troubling turn of events, but pay it little mind: As our ­experts are busy with their own #Resistance, a real resistance is unfolding in Iran.

Liel Liebovitz is a senior writer for Tablet. Twitter: @Liel