U.S. stocks mounted a late-session rally to close higher on Wednesday after an increase in oil prices helped reduce investors' fears about banks' vulnerability to energy companies struggling to pay their debts.
Nine of the 10 major S&P sectors rose, with the materials index .SPLRCM up 0.99 percent.
The S&P energy sector .SPNY gained 0.9 percent, trimming its loss in 2016 to 27 percent after U.S. crude futures settled nearly 1 percent higher.
Crude prices near 2003 lows have hammered the earnings of U.S. energy companies, exacerbated fears of a slowing global economy and created turbulence on Wall Street that has left the S&P 500 almost 6 percent weaker since the start of the year.
The three major indexes moved higher toward the end of the day after trading deep in negative territory.
"You have a tremendous amount of underperformance out there in the hedge fund community," said Ian Winer, director of trading at Wedbush Securities in Los Angeles. "When the market starts to turn, it starts to feed on itself because people can't afford to miss out on a rally."
The S&P financial sector .SPSY, already the worst performing sector this year, fell 0.2 percent, with shares of Wells Fargo (WFC.N) down 1.02 percent.
JPMorgan (JPM.N) ended flat after it flagged declining investment banking revenue and raised its provisions for energy loan losses.
The Dow Jones industrial average .DJI rose 0.32 percent to end at 16,484.99 points and the S&P 500 .SPX gained 0.44 percent to 1,929.8. The Nasdaq Composite .IXIC added 0.87 percent to 4,542.61.
Facebook (FB.O) rose 1.34 percent and Apple (AAPL.O) added 1.49 percent. Concerns about slowing iPhone sales had pushed Apple's stock down 19 percent in the past three months.
After the bell, Salesforce.com (CRM.N) surged 6 percent after its fourth-quarter results reduced fears of a slowdown in software spending.
During the session, Target Corp (TGT.N) climbed 3.99 percent after its quarterly sales showed the store's turnaround efforts were gaining traction.
Ford (F.N) declined 2.74 percent and General Motors (GM.N) lost 1.84 percent after Credit Suisse said it was a "poor time" to own auto stocks.
Advancing issues outnumbered declining ones on the NYSE by 1,952 to 1,086. On the Nasdaq, 1,759 issues rose and 1,003 fell.
The S&P 500 index showed 11 new 52-week highs and five new lows, while the Nasdaq recorded 22 new highs and 98 lows.
About 8.1 billion shares changed hands on U.S. exchanges, below the 9 billion daily average for the past 20 trading days, according to Thomson Reuters data.
(Additional reporting by Abhiram Nandakumar in Bengaluru; Editing by Meredith Mazzilli)