Investors also got a welcome respite from the recent turmoil in overseas markets, particularly in Turkey and Argentina.
The Standard & Poor's 500 index rose 19.99 points, or 1.1 percent, to 1,794.19, with all 10 sectors of the index closing higher. That more than made up the 18.29 points the index lost on Wednesday.
The Nasdaq composite jumped 71.69 points, or 1.8 percent, to 4,123.13 and the Dow Jones industrial average rose 109.82 points, or 0.7 percent, to 15,848.61.
Facebook jumped $7.55, or 14 percent, to $61.08. The social media company reported results late Wednesday that exceeded the expectations of financial analysts. Facebook's adjusted profit was 31 cents per share, four cents better than forecast.
It wasn't all good news out of the technology sector. Amazon.com sank in after-hours trading after releasing results that fell short of what investors were expecting. The stock of the online retailing pioneer dropped $35.47, or 9 percent, to $367.54.
In other earnings news, Visa rose $3.76, or 2 percent, to $220.88 after the company reported a 9 percent rise in first-quarter profits, beating expectations.
Alexion Pharmaceuticals was the biggest advancer in the S&P 500, rising $28.27, or 21 percent, to $162 after the company also beat analysts' expectations and gave a strong 2014 outlook. Alexion is a specialized drug maker focused on rare genetic diseases.
Alexion helped lift the stocks of other drugmakers. Dow members Merck and Pfizer each rose more than 2 percent. Specialized drugmakers Gilead Sciences and Biogen were up 2 percent and 4 percent, respectively.
Investors also cheered news that U.S. economy grew at a 3.2 percent annual rate in the final three months of 2013, a positive sign for the economy in 2014. Consumer spending, a major driver of the U.S. economy, picked up in the quarter.
''It was a good, balanced GDP report,'' said Sean Lynch, global investment strategist with Wells Fargo Private Bank, which manages $170 billion in assets.
Even with Thursday's gain, it's been a difficult month for investors. The Dow is down 4.4 percent in January, the worst start to a year since 2009.
Emerging markets worries drove most of the sell-off over the last two weeks. A survey last week confirmed that manufacturing in China, the world's second-biggest economy, slowed in January. And this week, the Turkish lira hit record lows, partly because a police bribery scandal there might destabilize the Turkish government.
In Argentina, the peso had its sharpest slide in 12 years earlier this month.
''The currency problems in the emerging markets caught a lot of people by surprise, and that overflowed in to U.S. markets,'' Lynch said.
Investors got a break from the troubles in emerging markets Thursday. The Turkish lira, Argentinian peso and the South African rand, another troubled currency, stabilized.
The iShares MSCI Emerging Markets ETF, an exchange-traded fund that tracks stocks located in less-developed countries, rose 1 percent after falling 1.5 percent the day before.
Even with Thursday's upturn, the broader trend in the market appears to be downward for the time being, strategists say. The Dow has risen only two out of the last eight trading days.
''I'm pretty focused on corporate earnings, and that's about it,'' said Ian Winer, director of trading at Wedbush Securities. ''Earnings have been OK, but not all that great. I think we're going lower, and I think (the sell-off this month) is just the beginning.''
Several investors have said the U.S. stock market will experience a ''correction,'' meaning a decline of 10 percent or more in a benchmark index like the S&P 500, sometime this year. That chorus has gotten louder in the last couple of weeks. The last time the market had a correction was in October 2011.
''The markets have been looking for a reason to pull back and certainly the emerging markets and currency problems gave them a reason to do so,'' Lynch said.
The bond market also had a day of stability. The yield on the U.S. 10-year Treasury note edged up to 2.70 percent from 2.68 percent the day before.