Facebook surged 15.5 percent in its biggest one-day leap since 2013 after the digital advertising behemoth smashed expectations with a 52-percent jump in fourth-quarter revenue.

Helped also by a 4.28-percent gain in Alphabet, the S&P tech sector surged 1.48 percent.

The S&P energy sector <.SPNY> rallied 3.15 percent, buoyed by a rise of almost 3 percent in oil prices due to speculation that Saudi Arabia and other OPEC countries would cut output to boost prices.

Optimism sparked by earnings from Facebook and a handful of other companies, as well as the bounce in oil prices, was behind most of the day's improved sentiment, investors said.

But they also warned the gains could be short-lived and that a steep selloff this year caused by weak oil and worries about China's economy may not be exhausted. The S&P remains down 7 percent for 2016.

"You had marquee names with pretty good earnings," said Chuck Carlson, chief executive officer at Horizon Investment Services in Hammond, Indiana. "I'd love to say we're onward and upward from here but I don't think things work that way."

The Dow Jones transport average <.DJT>, which Carlson said was a good indicator of the economy's health, fell 0.8 percent.

Others remained cautious after comments by the U.S. Federal Reserve's Open Market Committee on Wednesday did not more strongly signal it could scale back the pace of future interest rate hikes in the wake of recent turmoil in global markets.

"The FOMC's statement was less dovish than anticipated and very likely may have marked a top in the recent rebound we have seen," warned Mohannad Aama, Managing Director, Beam Capital Management LLC in New York.

The Nasdaq biotech <.NBI> index lost 3.5 percent and was on track for its biggest monthly fall in 16 years.

Abbott Labs was the biggest drag on the healthcare sector, with a 9.3-percent drop.

The Dow Jones industrial average <.DJI> gained 0.79 percent to end at 16,069.64 points while the S&P 500 <.SPX> added 0.55 percent to 1,893.36. The Nasdaq Composite <.IXIC> rose 0.86 percent to 4,506.68.

After the bell, Amazon slumped 11 percent after its quarterly report let down investors. Ahead of the report, it had risen 8.9 percent.

During the session, PayPal surged 8.39 percent and Under Armour jumped 22.59 percent. Revenue at both companies beat estimates.

Among the losers, eBay sank 12.45 percent after it forecast weaker-than-expected quarterly revenue and profit.

Advancing issues outnumbered decliners on the NYSE by 2,054 to 1,032. On the Nasdaq, 1,470 issues rose and 1,312 fell.

The S&P 500 index showed eight new 52-week highs and 24 new lows, while the Nasdaq recorded 13 new highs and 166 new lows.

About 8.8 billion shares changed hands on U.S. exchanges, above the 8.6 billion daily average for the past 20 trading days, according to Thomson Reuters data.

(Additional reporting by Abhiram Nandakumar in Bengaluru; Editing by Nick Zieminski)

By Noel Randewich