The Standard & Poor's 500 index was down 10 points and falling at 12:30 as traders reacted to a slump in overseas markets. It seemed headed for another sell-off like Wednesday's 22-point drop. But the index reversed course and rose the rest of the day. It closed with a gain of 13.66 points, or 0.9 percent, at 1622.56.
The gain broke a two-day losing streak as traders looked ahead to the government's monthly employment report Friday.
Retail stocks mostly rose after several store chains reported higher sales for May. Costco gained $1.92, or 1.8 percent, to $111.09.
Financial markets have turned volatile over the past two weeks as traders parse comments from Federal Reserve officials for hints about when the bank will cut back on its support for the economy. A batch of weak manufacturing reports has also heightened concerns about the economy's strength. The S&P 500 index has lost 2.8 percent since reaching a record high on May 21.
One concern for some investors is the recent rise in long-term interest rates. Those rates will likely climb further when the economy improves and the Fed scales down its monthly purchases of $85 billion in bonds. Rates remain near historically low levels.
"As interest rates come back to more normal levels, it's probably going to cause volatility," said Tim Speiss, chairman of the personal wealth advisers practice at EisnerAmper. "But that should be viewed as healthy."
The Dow Jones industrial average rose 80.03 points, or 0.5 percent, to 15,040.62. It had been down as much as 116 points.
The Nasdaq composite index rose 22.58 points, or 0.7 percent, to 3,424.05.
The U.S. market slumped at midday, following European markets lower, when the European Central Bank's president, Mario Draghi, said that the bank wouldn't take more steps to support Europe's ailing economies.
Stock indexes fell 2.6 percent in Italy, 1.2 percent in Germany and 1 percent in France. The yield on Spain's 10-year government bond spiked to 4.65 percent from 4.41 percent as demand for the bonds dropped.
In the market for U.S. government bonds, the yield on the 10-year Treasury note edged down to 2.07 percent from 2.09 percent late Wednesday.
The yield, which acts as a benchmark for mortgages and other loans, has climbed steadily since hitting a recent low of 1.63 percent May 3. That's when the government reported a surge in hiring over the previous three months. Expectations that the Fed will ease back on its bond-buying sometime soon are prompting traders to sell bonds, pushing yields higher.
Economists predict that employers added 170,000 jobs last month. A report that's much better or worse than expected can drive trading for weeks afterward.
Last month, for instance, news of the hiring surge and a drop in the unemployment rate to 7.5 percent, a four-year low, pushed the S&P 500 above 1,600 for the first time.
David Joy, chief market strategist at Ameriprise Financial, said Friday's report is especially important for investors because the Fed has made it clear that the job market will determine whether the bank pulls back on or extends its bond-buying effort.
"We're in a battleground between what the Fed is going to do and what the economy is going to do, and there's no clear direction on either," Joy said.
Gold jumped $17.30 to $1,415.80 an ounce. The price of crude oil crossed above $95 per barrel following a report from the Energy Department that the country's oil supply shrank last week. Oil rose $1.02 to $94.76 a barrel.
Among other stocks making big moves:
Chatter that PepsiCo may be interested in buying SodaStream sent the Isreali company's stock up 3 percent, even though PepsiCo called the speculation "totally untrue." SodaStream's stock gained $1.89 to $71.24.
VeriFone Systems plunged 21 percent. After the market closed Wednesday, the provider of terminals for credit-card payments reported quarterly results that fell short of financial analysts' estimates. The lower results were a result of a charge for legal fees and sliding sales. VeriFone also forecast earnings of 20 cents in the current quarter, half of what analysts had forecast. The company's stock sank $4.58 to $17.37.