The US airstrike killing of Iran’s top general rattled investors Friday, putting the brakes on the stock market’s recent rally as oil and gold prices jumped.

Stocks largely lost big gains from Thursday, when the three major indexes posted new record highs, after the killing of Gen. Qassim Soleimani raised fears of reprisal by Iran, whose supreme leader Ayatollah Ali Khamenei promised “harsh retaliation.”

The Dow Jones Industrial Average was down 233.92 points, or 0.81 percent, at 28,634.88 at Friday’s close.

The S&P 500 fell 23 points, or 0.7 percent, lower, while the Nasdaq composite fell 71.42 points, or 0.79 percent, at 9,020.77.

The Friday strike at Baghdad International Airport, which President Trump ordered amid growing tensions with Iran, served as a “catalyst” for sell-offs in the stock market after a long run of gains, according to Quincy Krosby, chief market strategist for Prudential Financial.

“Obviously much is going to depend on the headlines, because the larger question is, is this the beginning of an escalation and a broadening of the Middle East conflict?” Krosby told The Post.

Oil prices went the opposite direction amid fears that trouble in the Middle East could dampen supply. Brent crude prices rose slightly, to $68.65 a barrel.

Gold, viewed by investors as a safe haven in times of trouble, jumped 1.7 percent to $1,553.80 per ounce, nearing a six-year high.

In another sign of a spooked market, the CBOE Volatility Index jumped nearly 30 percent Friday to an intraday high of $16.20. It was trading up 9.3 percent at $13.63 as of 1:36 p.m.

While oil price spikes indicated fears about further supply disruptions in the Middle East, market observers said those worries were fairly muted given the US’s strength as an oil supplier.

“The fear that somehow oil prices are going to skyrocket the way they did in the ‘70s, for example — that fear has dissipated as we have become an important exporter of oil,” Krosby said.

Friday’s market volatility wasn’t any greater than normal — though developments in the Iran conflict could cause more shakeups, according to Brad McMillan, chief investment officer at Commonwealth Financial Network.

“Any damage to your investments is likely to be relatively small and short term,” McMillan wrote in a Friday commentary. “… As a citizen, I am paying attention and concerned. As an investor, not so much.”