Iran's launching of more than a dozen missiles at American-led forces in Iraq on Wednesday came after years of preparing for a confrontation with its superpower foe, whose forces are vastly larger and more advanced.
The Gulf country has more than 500,000 active-duty personnel, including 125,000 members of its elite Revolutionary Guards, according to a report last year by the International Institute for Strategic Studies. But international sanctions and restrictions on arms imports have made it hard for Iran to develop or buy more sophisticated weaponry.
To compensate for the imbalance, Iran has developed "asymmetrical" responses - ballistic missiles, deadly drones and a web of militia allies in Iraq, Syria, Lebanon and Yemen, among other things - with the aim of being able to inflict pain while avoiding the traditional battlefield.
"From a conventional military perspective they would get absolutely hammered," said a British former military commander who asked not to be identified because of the sensitivity of the matter. "Their conventional military is very, very sparse and quite old and quite out of date. They've spent all their money on asymmetric attack capabilities. In that regard they're very well prepared."
Until Wednesday, the strategy had deterred a direct conflict with the US as tensions spiked since Washington quit a multi-lateral nuclear deal in 2018 and reimposed sanctions.
Gulf rival Saudi Arabia recently witnessed the damage that missile and drone assaults can cause, after a strike on its oil facilities last year briefly halved production and knocked out 5% of global crude supply. Riyadh and Washington blamed Iran for the attack, a charge Tehran denied.
Iran has built the largest stockpile of ballistic missiles in the Middle East. Some are based on the older, widely used "Scud" designs, with a range of at least 750km (466 miles). Others, based on the North Korean No Dong, can reach up to 2,000km, within reach of Israel or southeast Europe, according to a US Defense Intelligence Agency (DIA) report last year.
The Revolutionary Guards fields a fleet of missile-armed speedboats and midget submarines it can deploy against US military ships or commercial tankers to disrupt the flow of oil in Gulf waters, where Washington says Tehran attacked six tankers last year.
"If you look at ships, tanks, jet fighters, Iran looks very weak. But if you're looking at anti-ship missiles, ballistic missiles, UAVs and things like that then it looks a lot more capable," said Jeremy Binnie, Middle East and Africa editor for Jane's Defence Weekly.
Iran's fleet of unmanned aerial vehicles (UAVs) can be used for surveillance or armed with explosives, according to military experts.
"Iran in the Persian Gulf doesn't really need to have big ships, not necessarily frigates and destroyers. Speedboats, gun boats, missile boats can do the job," said Hossein Aryan, a military analyst who served 18 years in Iran's navy before and after the 1979 Islamic revolution.
Major-General Qassem Soleimani, whose killing in a US drone strike in Baghdad last week sparked the Iranian retaliation on Wednesday, was the head of the Revolutionary Guards Quds Force. The group handled clandestine operations outside Iran, working closely with allied military forces and militias in Iraq, Syria and Lebanon.
Iran's leaders have promised harsh reprisals over the death of Soleimani, who was a national hero to many Iranians but considered a dangerous villain by Western governments.
He was buried in Iran on Tuesday after tens of thousands mourned him in a ceremony led by Iran's supreme leader.
US officials have said Soleimani was killed because intelligence indicated forces under his command planned attacks on US targets in the region, although they have provided no evidence.
Democrats in the US Congress and some of the party's presidential contenders warned that the escalating conflict could spark a wider war in the Middle East.
Lebanon's Hezbollah, along with a handful of the Iraqi militias closely allied with Iran, have already pledged to take revenge against American forces for Soleimani's death.
More than 5,000 US troops are in Iraq along with other foreign forces as part of a coalition that has trained and supported Iraqi security forces against the threat of Islamic State militants.
American troops are also stationed at bases in Kuwait, Saudi Arabia, the United Arab Emirates and Qatar, which hosts Al-Udeid air base, the largest US military facility in the region. Bahrain is headquarters of the US Navy's Fifth Fleet.