As it braces for an expected retaliatory strike from Israel, Iran has ordered the armed forces to be prepared for war but also to try to avoid it, having witnessed the decimation of its allies in Lebanon and Gaza.

Four Iranian officials said in telephone interviews this week that the supreme leader, Ayatollah Ali Khamenei, has ordered the military to devise multiple military plans for responding to an Israeli attack. The scope of any Iranian retaliation, they said, will largely depend on the severity of Israel’s attacks. They spoke on the condition of anonymity to discuss military preparations.

If Israeli strikes — a response to a barrage of missiles from Iran earlier this month — inflict widespread damage and high casualties, they said, Iran will retaliate. But if Israel limits its attack to a few military bases and warehouses storing missiles and drones, Iran might well do nothing.

The officials said Ayatollah Khamenei had directed that a response would be certain if Israel strikes oil and energy infrastructure or nuclear facilities, or if it assassinates senior officials.

The officials, including two members of the Islamic Revolutionary Guard Corps, said that if Israel inflicted major harm, the responses under consideration included a barrage of up to 1,000 ballistic missiles; escalated attacks by Iranian proxy militant groups in the region; and disrupting the flow of global energy supplies and shipping moving through the Persian Gulf and the Strait of Hormuz.

Iran publicly maintains that it does not want war. But punishing military blows from Israel would pose a challenge to its leaders, who are intent on not appearing weak and vulnerable, particularly after Israel’s assassinations of multiple leaders of Hamas and Hezbollah. Both of those groups are backed by Iran.

Thank you for your patience while we verify access. If you are in Reader mode please exit and log into your Times account, or subscribe for all of The Times.

Thank you for your patience while we verify access.

Already a subscriber? Log in.

Want all of The Times? Subscribe.