Stocks rose on Wednesday after President Donald Trump's comments on the Iran conflict eased worries of further escalation in U.S.-Iranian tensions.
The Dow Jones Industrial Average gained 161.41 points, or 0.6% to close at 28,745.09. The Nasdaq Composite advanced 0.7% to 9,129.24 and notched intraday and closing records. The S&P 500 climbed 0.5% to 3,253.05and hit an intraday all-time high.
The Dow was up as much as 282 points, or 1%. The S&P 500 and Nasdaq gained as much as 0.9% and 1.1%, respectively. In the final minutes of trading, the major averages came off their highs amid unconfirmed reports of explosions near Baghdad's Green Zone.
Trump said Iran appeared to be "standing down" after that nation attacked the Ain al-Asad airbase overnight. However, he added the U.S. will "immediately impose additional punishing economic sanctions on the Iranian regime." News of the attack sent stock futures tumbling overnight.
"Now, as the president has to some degree defused some of the anxiety, so you're getting … a little bit of a sigh of relief rally here," Art Cashin, director of floor operations at the NYSE for UBS, said on CNBC's "Squawk Alley."
Oil futures fell from their highest levels of overnight trading, lowering concerns of a possible surge in fuel prices. WTI crude futures were up more than 4% at one point, but settled down nearly 5%.
The president's comments pressured safe havens such as gold as investors flocked back into riskier assets. Gold futures for February delivery dropped 0.9% to settle at $1,560.20 per ounce. Overnight, the precious metal jumped to its highest level in about seven years.
Investors around the globe had been bracing themselves for a bigger conflict between Iran and the U.S. after last week's killing of Gen. Qasem Soleimani, a top-ranking Iranian military official. But Trump said there were no American casualties from Tuesday night's airstrikes. The attacks did not target oil infrastructure, boosting investor sentiment as well.
At their worst levels in overnight trading, S&P 500 futures were down more than 1.6% along with Nasdaq 100 futures. Dow futures lost more than 400 points overnight as news of the attack started to surfaced.
Stocks had been under pressure since last week after news of Soleimani's death while oil surged, stoking fears of a sharp rise in fuel prices that could dent an already fragile economy. In December, the U.S. manufacturing sector had its biggest contraction in more than a decade.
But Wall Street has history on its side as previous U.S.-Iran crises have seldom led to a prolonged market downturn. Data from Barclays shows that the S&P 500 averages a gain of nearly 3% three months after a confrontation between the two countries. That average gain grows to 5.5% after six months.
"The situation we have today is way different than what we had 10 years ago," said Scott Ladner, chief investment officer at Horizon Investments. "The U.S. energy renaissance and the shale revolution has turned the U.S. into the marginal oil producer in the world. That's really put a cap on how high oil can get."
"The prospect of having a 30% or 40% spike in oil over a short period of time — which can lead to very bad economic outcomes — is way lower now than it was even a decade ago," Ladner said.
Boeing shares dropped 1.8%, weighing on the Dow. A Ukraine International Airlines Boeing 737 airliner burst into flames shortly after takeoff from Tehran, Iran, on Wednesday, killing all 176 people aboard in a crash that an initial report blamed on engine failure. Ukrainian officials later said, however, that the cause of the crash was yet to be determined.
— CNBC's Michael Bloom contributed to this report.