U.S. stocks shook off an early slide and closed broadly higher Thursday as the market steadied after its worst drop in more than four months.

The S&P 500 rose 1.2%, bouncing back from a drop of 0.3% in the early going. Traders welcomed encouraging data on the pace of layoffs and how powerfully the economy rebounded during the summer from its coronavirus-induced coma. Economists warn big challenges still lie ahead, though. The S&P 500 was coming off a 3.5% tumble Wednesday on worries the worsening pandemic will drag down the economy and corporate profits again.

A strong rebound in technology sector stocks helped power the rally ahead of widely anticipated quarterly report cards from Facebook, Amazon and Google’s parent company. The three Big Tech companies each reported results after the close of regular trading that topped Wall Street’s expectations.

“If you look at the leadership today, it’s back to the mega-cap names,” said Willie Delwiche, an investment strategist at Baird. “It’s in anticipation of good earnings this evening when you have a whole swath of companies reporting.”

The S&P 500 rose 39.08 points to 3,310.11. The gain was less than half of what the benchmark index lost a day earlier. The Dow Jones Industrial Average gained 139.16 points, or 0.5%, to 26,659.11. The index had been down 229 points and as high as 371 points.

The tech-heavy Nasdaq composite fared better than the rest of the market. It climbed 180.72 points, or 1.6%, to 11,185.59.

The major stock indexes are still on track to post weekly losses, including the second straight weekly decline for the S&P 500.