The fury also reflected broader grievances over an economy that has suffered under sanctions that President Trump imposed after he pulled the United States out of a multilateral accord designed to check Iran’s nuclear program. Iran’s hard-line leaders know that a war with the United States could profoundly worsen joblessness and economic anxiety — and perhaps threaten their political legitimacy.

But experts said some of those hard-liners may see war with the United States as a means of jump-starting Iran’s so-called resistance economy, and of stoking the nationalist anger that has helped to keep them in power.

Related: For President Trump, who as a presidential candidate criticized America’s wars in the Middle East, the specter of conflict with Iran threatens to alienate voters who see the Republican Party as indifferent to the human cost of war.

Go deeper: Our reporter spoke with American military personnel who witnessed Iran’s attack last week on U.S. forces stationed at Iraqi military bases, a retaliation for President Trump’s decision to kill a top Iranian commander, Maj. Gen. Qassim Suleimani.

Plus: Kimia Alizadeh, the only female athlete to win an Olympic medal for Iran, announced over the weekend that she had defected from the country because of its “hypocrisy, lies, injustice and flattery.”