Stocks overcame an early stumble and closed broadly higher Wednesday as the market more than made up its losses from a day earlier.
Retailers, health care and industrial companies notched solid gains. Financial and energy stocks also helped power the rally.
The two sectors have taken the heaviest losses this month as fear that the U.S. trade war with China is hampering global economic growth roiled markets.
"Markets are trading higher as investors await news on the China trade front," said Cayman Wills, global head of equities at J.P. Morgan Private Bank. "It's just the absence of bad news that's letting markets trade higher."
Evidence of investor anxiety could still be found in the bond market, as traders seeking safety snapped up U.S. government bonds. The trend continued to drive long-term bond yields further below short-term ones. The so-called inversion of the U.S. yield curve is a rare phenomenon that has correctly predicted previous recessions.
The yield in the 10-year Treasury fell below that of the two-year Treasury on Tuesday and remained lower Wednesday. The 10-year yield slid to 1.47%, down from 1.49% late Tuesday. The two-year dropped to 1.50% from 1.52%.
"You're seeing investors hedge their bets, but also take advantage of the pockets of opportunity in sectors that have been hurt by the 10-year yield coming down," said Quincy Krosby, chief market strategist at Prudential Financial.
The S&P 500 rose 18.78 points, or 0.7%, to 2,887.94. The Dow Jones Industrial Average climbed 258.20 points, or 1%, to 26,036.10. The Nasdaq recovered from an early slide, gaining 29.94 points, or 0.4%, to 7,856.88.
Investors favored smaller company stocks a day after they fell sharply. The Russell 2000 index rebounded 16.67 points, or 1.1%, to 1,472.71.
The market is on track to end the week with a gain after having declined the past four weeks in a row. Still, with two trading days left in August, the major indexes are down more than 3%. If those losses hold, August would be the second monthly drop for the market this year after May.
Uncertainty over the U.S.-China trade conflict and it impact on corporate profits has rattled investors this month. Investors' anxiety has been particularly visible in the demand spike for U.S. government bonds.