To solve the problem, the U.S. fired the missiles from warships in the Persian Gulf on a course over Iran’s mountains — using them as navigational landmarks — before they turned and proceeded toward their pre-programmed targets in the Iraqi capital.

Tehran wasn’t given any prior notification or even a formal heads-up about this. Nor was Iran a member of the coalition against Iraq. The coalition also planned to launch Tomahawks from the eastern Mediterranean over Syria and Turkey, but later scuttled these overflights.

Coalition military commanders weren’t certain everything would go according to plan — and took precautions in case something went wrong.

“[Navy planners] also seeded the missiles’ software with a ‘friendly virus’ that scrambled much of the sensitive computer coding during flight in case a clobbered Tomahawk fell into unfriendly hands,” the Washington Post reported.

Pres. George H.W. Bush’s advisers were “flabbergasted” at the decision to launch the missiles over Iran, the Post reported.

“We were dealing with neighboring countries who we didn’t want to join the fray,” Vice Adm. Stanley Arthur, the commander of the coalition’s naval forces, told PBS in 1996. “We had never used them in conflict before and there was a lot of apprehension about, ‘Do we launch these things and then they make up their own mind about where they are going?’”

“Downtown Tehran would not have been a good mission,” Arthur added.

No country would be happy with errant missiles crashing into its own territory — least of all Iran. A desolate Iranian mountaintop would have been one thing, but a populated urban area would have been a disastrous blunder.

Iran was only just recovering from its devastating war with Iraq which had raged throughout the 1980s. The war claimed hundreds of thousands of lives. Saddam Hussein’s Scud missiles relentlessly bombarded Iranian cities and the country’s civilian population. Iran retaliated with Scud missiles of its own.

The Persian Gulf War began only three years later. It also wasn’t long after a U.S. Navy warship shot down Iran Air 655 — killing 290 people.

American missiles with 1,000-pound warheads crashing into Iranian territory would have likely worsened already estranged relations. But Tehran didn’t react to those overflights, and none of the missiles crashed into Iran … that we know about.

Later flights into Iran’s territory during that war would come in the form of Iraqi air force MiG and Sukhoi jets. These planes landed in Iranian bases to avoid being bombed on the ground or shot out of the sky by coalition forces.

Iran seized the Iraqi planes and incorporated them into its air force, where several still remain in active service. Among those planes were Su-25 Frogfoots, which flew back into Iraq last year to fight Islamic State.

But even though later Tomahawk variants are more accurate, they can still veer off course. During the 2003 U.S. invasion of Iraq, 10 GPS-guided Tomahawks crashed in Iran, Turkey and Saudi Arabia.

In Turkey, angry locals threw eggs and rocks at American advisers when they arrived to inspect one of the crash sites. The accident provoked conspiracy theories about an imminent American invasion of Turkey.

Fortunately, none of the stray missiles exploded or killed anyone. But it was still bad enough, and the U.S. halted Tomahawk launches from the Red Sea and the Mediterranean.

Which goes to show that precision-guided weapons are hardly fail-proof.