S&P 500 rises on strong earnings, closing out the best January since 1987

Stocks rose to close out their best January in three decades as strong earnings and a Federal Reserve indicating it will pause rate hikes caused investors to rush back into the market following a vicious December sell-off.

The gain on Thursday was driven by better-than-expected earnings from a range of companies, including Facebook and General Electric. The S&P 500 gained 0.9 percent to close at 2,704.10 and the Nasdaq Composite outperformed, rising 1.37 percent to 7,281.74. The Dow Jones Industrial Average closed just below the flatline at 24,999.67.

The S&P 500 jumped 7.87 percent this month, its best January performance since 1987, and its biggest monthly gain since October 2015. The Dow rose 7.17 percent in January, its largest one-month rise since 2015 and biggest January gain in 30 years.

Shares of Facebook surged 10.8 percent after the company's quarterly results easily topped expectations. GE shares jumped 11.65 percent on stronger-than-forecast revenue. These results come during the busiest week of the corporate earnings season.

"We're close to fair value," said Dave Lafferty, chief market strategist at Natixis Investment Managers. "It feels like a lot of this was a pop from fairly oversold levels in the fourth quarter. The market sort of ran away with itself to the downside and it's come back."

Last month, the S&P 500 fell 9.18 percent and briefly dipped into bear-market territory on an intraday basis on Christmas Eve. Since Dec. 24, however, stocks have been on a tear, with the S&P 500 rising about 15 percent.

The market is now "thinking about what is the next catalyst," Lafferty of Natixis said. "It doesn't feel, to me, like this pop in January is the beginning of a big new move. It feels like it was just a rebound from oversold levels."

The market got a boost in the final minutes of trading Thursday after President Donald Trump told reporters in the Oval Office he hoped to strike a deal with China before the march deadline. A translator also presented Trump with an optimistic letter from Chinese President Xi Jinping.

Other companies that reported better-than-expected earnings on Thursday included UPS, which rose 4.16 percent. Charter Communications, meanwhile, rose more than 14 percent after reporting better-than-expected quarterly sales.

Big Wednesday pop

The rise Thursday follows a rally from Wednesday, sparked by the Federal Reserve's latest monetary policy statement. The Fed said it will be "patient" with raising rates moving forward. The Fed also addressed the balance sheet, which had been a concern for investors, in a separate statement. The Fed said it "is prepared to adjust any of the details for completing balance sheet normalization in light of economic and financial developments."

"Markets are rebounding and some recession fears are fading. Central banks have blinked, moderating their hawkish stance," Alberto Gallo, head of macro strategies at Algebris Investments, wrote in a note. "If we look at monetary policy today, there are relatively low risks that the Fed may turn aggressively hawkish, ending the cycle prematurely."

Investors also monitored ongoing U.S.-China trade negotiations. Two sources told CNBC that U.S. and Chinese officials are talking about arranging a meeting between Presidents Donald Trump and Xi Jinping for late February.

Not everyone participated in Thursday's rise, however. Microsoft fell 1.8 percent after the company reported weaker-than-expected revenue and earnings that barely beat expectations. The tech giant also issued quarterly earnings guidance that was lower than expected. DowDuPont, another Dow member, fell 9.2 percent on the back of mixed quarterly results. Tesla shares dipped 0.5 percent on the back of weaker-than-expected earnings. The company also said its CFO was leaving his post.

Spriha Srivastava contributed to this report.