Investors set aside some concerns about mounting debt levels around the world and looked for bargains after a two-day slide in stocks.
Stocks turned higher late Wednesday after a day of back-and-forth trading. Investors have been cautious about rising government debt levels in Spain, Greece and other countries.
The Dow Jones industrial average rose 51 points to regain about half of what it lost a day earlier.
Investors spent much of the day looking for safety following a decision by credit rating agency Standard & Poor's to reduce the outlook on Spain's debt rating Wednesday.
S&P's move came a day after another agency lowered its credit rating on Greece's government. Investors have been watchful for other signs of problems with global debt ever since a state-run company in Dubai shocked investors two weeks ago by asking its creditors for a debt reprieve.
Meanwhile, stocks again followed moves in the dollar, as they have for months. When it falls, the dollar makes commodities cheaper for foreign buyers and increase profits for U.S. companies that do business outside the U.S.
The dollar has steadied this week against other major currencies, interrupting a steady drop since March. The greenback has fallen as investors take advantage of cheap financing to invest in riskier, higher-yielding assets like stocks and commodities. Signs that the economy is improving have cut into demand for safe-haven investments.
In recent weeks, however, investors have been shuttling between buying stocks and hoarding cash as they try to lock in some of the big gains they've amassed in stocks since a rally started in March.
As the end of the year approaches, many investors have been building up defensive investments like Treasurys. The uncertain tone in the market, combined with light trading volume, has made for choppy trading, which analysts expect to continue through the rest of the year.
Tom Phillips, president of TS Phillips Investments in Oklahoma City, said he expects the dollar will lose its pull over the stock market because so many traders have placed bets that the currency will fall and boost stocks.
“When everybody understands the game the game doesn't work as well,” he said. “I think it will just fray and start to erode.”
According to preliminary calculations, the Dow Jones industrial average rose 51.08, or 0.5 percent, to 10,337.05 after falling 104 on Tuesday. The Standard & Poor's 500 index rose 4.01, or 0.4 percent, to 1,095.95, while the Nasdaq composite index rose 10.74, or 0.5 percent, to 2,183.73.