NEW YORK (AP) -- Markets unclenched on Wednesday, and U.S. stocks neared records on hopes that the United States and Iran are backing away from the edge of war.
The rally capped a whirlwind day of reversals that swept through markets around the world. Stocks initially reeled after Iran fired missiles at two bases in Iraq housing U.S. troops, retaliation for a U.S. drone strike that killed a top Iranian general last week.
Gold soared overnight as investors scrambled for safety, crude jumped on fears a war would squeeze oil supplies and the futures market suggested U.S. stocks would drop sharply as soon as trading opened in New York. But the selling abated as reports suggested no Americans died and after Iran's foreign minister said his country had concluded "proportionate measures in self-defense."
When trading opened, the S&P 500 climbed modestly higher, and it more than tripled its gain after President Donald Trump confirmed that no Americans were hurt and that Iran "appears to be standing down."
Trump said he'd add economic sanctions on Iran, but he also said that the United States is "ready to embrace peace with all who seek it." That fit with the market's hopes that no further military escalations may be on the way, at least for now.
Not only did stocks climb, crude oil ended up slumping sharply and gold fell for the first time in 11 days. Treasury yields rose in a sign of optimism, and a measure of fear in the stock market eased.
The S&P 500 rose 15.87 points, or 0.5%, to 3,253.05. It had been up as much as 0.9% earlier in the day and was on track to set a record, but the gains moderated in the last half hour of trading.
The Dow Jones Industrial Average rose 161.41, or 0.6%, to 28,745.09. The Nasdaq composite set a record after rising 60.66, or 0.7%, to 9,129.24.
The stock market has historically bounced back quickly from geopolitical shocks, such as Friday's U.S. killing of Iranian Gen. Qassem Soleimani, as long as they don't result in a war and recession, said Linda Duessel, senior equity strategist at Federated Investors.
"Geopolitical shocks have resulted in sharp, short pullbacks, much of which is recovered in the next few months, and I suspect everyone in this business knows that data point and uses any opportunity to buy up stocks," she said.
With central banks around the world pushing stimulus and U.S. households remaining resilient amid a solid job market, Duessel said she thinks the U.S. economy is likely to keep growing unless an actual war breaks out or inflation unexpectedly bursts higher.
"You don't get into trouble in the market unless recession is on the horizon," she said, "and we have a very hard time putting together a scenario where we have a recession anytime soon."
A government report on Friday will give the latest update on the health of the job market, which has been key in propping up the economy despite weakness in manufacturing caused by Trump's trade wars. Economists expect Friday's report to show that employers added 160,00 jobs last month, and a report on Wednesday suggested hiring in the private sector may have been stronger in December than economists forecast.
Benchmark U.S. crude jumped as high as $65.65 per barrel in overnight trading, when worries about possible disruptions to oil supplies were at their peak. But the price sank through the day, with losses accelerating after a U.S. government report showed that the amount of oil supplies in inventories rose last week.
Benchmark U.S. crude fell $3.09, or 4.9%, to settle at $59.61. Brent crude, the international standard, lost $2.83, or 4.1%, to $65.44 per barrel.
Gold had a similar whipsaw day. It had climbed as high as $1,604.20 per ounce in overnight trading before settling at $1,557.40, down $14.40.
Stock indexes slumped sharply in Asia, but the selling eased as trading moved westward through the day.
Japan's Nikkei 225 index lost 1.6%, South Korea's Kopsi dropped 1.1% and the Hang Seng in Hong Kong fell 0.8%. In Europe, Germany's DAX returned 0.7%, and France's CAC 40 rose 0.3%. The FTSE 100 in London was virtually flat.
The yield on the 10-year Treasury sank as low as 1.70% when worries were at their height, but they climbed through the day and were at 1.87% in afternoon trading, up from 1.82% late Tuesday. Treasury yields tend to rise with investor optimism about the economy's prospects.
Walgreens Boots Alliance fell 5.8% for the biggest loss in the S&P 500 after reporting weaker earnings for the latest quarter than analysts expected.
In commodities trading, wholesale gasoline fell 7 cents to $1.65 per gallon. Heating oil fell 7 cents to $1.96 per gallon. Natural gas fell 2 cents to $2.14 per 1,000 cubic feet.
The price of gold fell $14.40 to $1,557.40 per ounce. Silver fell 23 cents to $18.09 per ounce and copper rose 2 cents to $2.82 per pound.
The dollar rose to 109.22 Japanese yen from 108.53 yen on Monday. The euro fell to $1.1111 from $1.1145.