Stocks rose on Thursday after comments from a top Federal Reserve official led to increasing bets that the central bank will ease monetary policy more aggressively.

The S&P 500 closed 0.4% higher at 2,995.11, led by a 0.8% gain in consumer staples. The Nasdaq Composite advanced 0.3% to 8,207.24. The Dow Jones Industrial Average ended the day up just 3.12 points, or 0.01%, at 27,222.97, after dropping as much as 151.06 points. The gains were the first for the indexes in three sessions.

The indexes turned around in the afternoon came after New York Federal Reserve President John Williams said the central bank needed to "act quickly" when the economy was slowing and rates were low. "It's better to take preventative measures than to wait for disaster to unfold," he said in a speech.

After Williams' comments, traders increased their bets that the Fed could go deeper than a quarter-point cut at its meeting in late July.

The market's gains, however, were kept in check as Wall Street digested a mixed batch of corporate earnings results.

Netflix shares plunged more than 10% after the streaming giant reported a surprise loss in U.S. subscribers coupled with slower-than-expected international membership growth. Those metrics — which are key for Netflix — offset a better-than-expected earnings per share result for the previous quarter.

"You had some price increases and a weaker slate but still, in general, it doesn't have anything to say about the consumer or the health of the economy. I think you might be getting an opportunity there, although you might have to be patient," said Tom Martin, senior portfolio manager at Globalt.

IBM shares, meanwhile, briefly fell at the open before recovering after the company reported its fourth consecutive revenue decline. Declining sales from IBM's IT division offset growth in its cloud business.

Morgan Stanley posted better-than-expected quarterly results, driven by its wealth management and fund divisions. The stock rose 1.5%.

"We're going to see companies beat on earnings," said Kate Warne, investment strategist at Edward Jones. "This will be a positive catalyst but not a very positive one."

But Warne said she is still optimistic on U.S. stocks as the Federal Reserve is likely to lower interest rates. "The support for the market is better now than it was last year."