US President Donald Trump’s decision to humiliate Iran with the assassination of a national hero on Jan. 2 is a calculated gamble and probably represents the best of a set of bad alternatives.

Trump inherited a weak hand after the George W. Bush Administration destroyed the century-old balance of power between Sunni and Shia in Western Asia, by replacing Saddam Hussein’s Sunni minority regime with a sectarian Shia government allied to Iran. Bush’s belief in majority rule and nation-building, lauded by his neoconservative advisers, handed Iran an opportunity to dominate the region. Trump pushed back with economic sanctions, which have not dissuaded Iran from extending its reach.

Iran provoked the United States by attacking its embassy in Baghdad after the US launched airstrikes against Iranian-backed militias in Iraq. Iran’s attack on the embassy sought to humble the United States. Trump decided to escalate rather than matching Iran tit-for-tat. Both actions involved high-risk gambles, and require an explanation. Iran crossed a red line by backing a militia attack on the US embassy and Trump crossed a red line by killing General Qasem Soleimani. Nations don’t take actions of this sort capriciously.

Iran’s regional strategy rests on a combination of irregular warfare based on Shia militias in Iraq, Syria and Lebanon, and strategic deterrence including intermediate-range missiles and cruise missiles. Iran revealed part of its strategic capability in September when Iranian infiltrators used ground-hugging cruise missiles and autonomous drones to destroy Aramco facilities in Saudi Arabia. Iran tested its “Khorramshahr “ missile with an estimated 2,000-kilometer range in 2017. It is not known how effective the weapon is or how many Iran possesses. It is possible that Iran has enough ordnance to swamp American anti-missile defenses at its Doha airbase or to overcome the air defenses on an American warship in the Persian Gulf.

Persia as such is a declining power. Its strategic position, as I have argued in the past, resembles France on the eve of the First World War. Today Iran has five workers of prime-age (25-64 years) for every citizen over 65. By 2050 the ratio will crash to just 1.8 working-age Iranians per retiree, assuming constant fertility. Iran’s economy will crash. Its pension systems already are bankrupt. Iran’s only hope of maintaining regional hegemony is to expand the Shia presence in Mesopotamia and the Levant, through militias like Lebanon’s Hezbollah and the 80,000-strong mercenary militias it supports in Syria, staffed mainly by Afghan and Pakistani Shia.

Iran’s problem, as Talleyrand told Napoleon, is that you can do anything you want with a bayonet except sit on it. To maintain its credibility in the Shia world Iran must continue to advance, and its advances run up against resistance from the United States in Iraq, and from Israel in Syria. Israel will not tolerate an Iranian proxy presence on its northern border next to the Golan Heights and has conducted thousands of airstrikes against Iranian assets in Syria. Russia recently complained that the intensity of these strikes has sharpened during the past few weeks.

Without attempting to read the minds of Iran’s leaders, one may conjecture that Iran badly needed a moral victory to show that it was not cowed by massive Israeli airstrikes in Syria, nor, indeed, by a deteriorating economy at home. In November, the Iranian regime ruthlessly suppressed anti-regime protests, killing up to 1,000 demonstrators. After the US struck five bases of Iran-backed militias in Iraq on Dec. 30, Iran decided that its credibility required a demonstration of power, and ordered the attack on the US embassy.

That left Trump with few good choices. After 5,000 dead, 50,000 wounded and trillions of dollars in expenditures in Iraq, the US had succeeded in turning a former counterweight to Iranian ambitions into an Iranian satrapy. The embassy attack was intended by Iran as a public act of ritual humiliation, and the United States had no choice but to respond. Trump chose to respond by subjecting Iran to an even more poignant form of humiliation, by assassinating a national hero, Gen. Qassam Sulemaini. It is easy to criticize the US president, but harder to recommend an alternative course of action. US airpower has limited effectiveness in constraining the diffuse Iranian-backed militias.

Neither Iran nor the US has good choices here. Iran must respond or its credibility will collapse. The question is how. An Iranian attack on an American ally like Israel or Saudi Arabia would not suffice, now that Washington has acted in its own name against a key Iranian leader. The indicated course of action is to attack an American asset. In the extreme case, Iran could use a combination of intermediate-range missiles, cruise missiles and drones to attack the Doha base.

The September attack on Aramco facilities in Saudi Arabia exposed the weakness of US air defenses. The Patriot anti-missile system can’t shoot anything flying lower than 60 meters, and Iran has low-flying cruise missiles. A successful strike against Doha certainly figures in American calculations. In late September, US Central Command temporarily moved command and control of the Doha base to a remote facility in Tampa, Florida, because the base is a “sitting duck” for Iranian missiles.

If Iran were to attack Doha, America’s response likely would be devastating. Two dozen missiles or bombing sorties could wipe out Iran’s economy in a matter of hours. Fewer than a dozen power plants generate 60% of Iran’s electricity, and eight refineries produce 80% of its distillates. A single missile strike could disable each of these facilities, and bunker-buster bombs of the kind that Israel used last month in Lebanon would entirely destroy them. Without much effort, the US could destroy the Port of Kharg from which Iran exports 90% of its hydrocarbons.

More likely is a limited attack, perhaps on a smaller US naval vessel in the Persian Gulf, or on a smaller US base somewhere in the region. That is difficult to calibrate: Iran would have to inflict sufficient damage to restore its credibility without inviting massive US retaliation.

Another consideration for the Trump Administration is the impact of such an exchange on the price of oil and the world economy. Even if the US were to destroy the Iranian economy, Iranian holdouts would remain dug in onshore of the Persian Gulf with enough artillery to shut down the waterway.

It seems clear that Iran was taken aback by the ferocity of America’s response to the embassy attack. If it anticipated this sort of attack, Gen. Sulemaini never would have appeared in person at the Baghdad Airport. Iran now has to devise a response whose outcome is extremely difficult to calculate. There is a significant probability of a major escalation.

Iran well may decide on a limited, symbolic action that fails to restore its credibility after the Sulemaini assassination. If it chooses restraint, its power in the region will diminish, and Trump’s gamble will pay off.

Preemptive strikes may be the most effective, and the most merciful course of action. I wrote in 2015:

“Most of the great wars of the past would have been far less bloody had they begun sooner. That emphatically is true of the First World War: if Germany had launched a preemptive assault on France during the First Morocco Crisis of 1905 before Britain had signed the Entente Cordiale with France and while Russia was busy with an internal rebellion, the result would have been a repeat of the Franco-Prussian War of 1870 rather than the ghastly war of attrition that all but ruined Western civilization. It was a tragedy that the vacillating Kaiser Wilhelm II rejected the counsel of his general staff and kept the peace. I do not mean to impute moral superiority to Wilhelmine Germany, but to argue, simply, that swift victory by one side was preferable to what followed. It is hardly controversial to argue that Britain and France should have prepared for war with Germany and preempted Hitler’s ambitions no later than the 1936 re-occupation of the Rhineland.”

Trump’s preemptive action yet may turn out to be a masterful stroke.