The loss of Mr. al-Muhandis was a profound one for the Iraqi fighters, who saw him not just as a militia leader close to Iran but also as someone who had helped rally the armed groups when they first formed in 2014 to fight the Islamic State as it threatened to sweep toward Baghdad, the Iraqi capital.

The militias have since been brought under the umbrella of the Iraqi security forces, and Mr. al-Muhandis was their deputy head.

Many declared: “Our men do not fear America; each man dies on his day. Your voice, Abu Mahdi, remains the loudest one.”

Iran can count on a range of assets in the region, including the Palestinian groups Hamas and Islamic Jihad in Gaza, Hezbollah in Lebanon, the Houthi rebels in Yemen and a range of fighting groups in Iraq and Syria that operate close to small contingents of American troops.

In recent months, Iran and its allies have struck oil facilities in Saudi Arabia and targeted tanker traffic in some of the world’s busiest shipping lanes in the Persian Gulf. A senior commander in Iran’s Islamic Revolutionary Guards Corps raised the prospect of possible attacks on ships in the gulf, saying that Iran would retaliate against Americans wherever they were within reach of the Islamic Republic.

Gen. Gholamali Abuhamzeh, the commander of the Guards in the southern province of Kerman, said on Friday in comments reported by the Tasnim news agency on Saturday: “The Strait of Hormuz is a vital point for the West, and a large number of American destroyers and warships cross there.”

He said Iran had long ago identified “vital American targets in the region,” and added, “Some 35 U.S. targets in the region as well as Tel Aviv are within our reach.”