U.S. stocks soared Thursday, with technology stocks leading the charge, as investors cheered a solid earnings report from Meta Platforms that showed resilience in the face of rising inflation.

The Facebook owner’s stock rose $30.78, or 18%, to $205.73 after the company said it had added more users than investors expected in the first quarter. That gain helped send the Nasdaq Composite Index up 382.59 points, or 3.1%, to 12871.53 and boosted the S&P 500 technology sector, which was the best performing group in the index.

The S&P 500 climbed 103.54 points, or 2.5%, to 4287.50, while the Dow Jones Industrial Average jumped 614.46 points, or 1.8%, to 33916.39. In the bond market, the yield on 10-year Treasury notes ticked up to 2.862% from 2.817%. Yields and bond prices move in opposite directions. Oil prices climbed, sending shares of energy companies higher, as government officials in Germany said the country is now ready to stop buying Russian oil. Benchmark Brent oil rose 2.2% to $107.59 a barrel.

Traders said the stock market was poised for a rally following recent selloffs in tech stocks, including a big swoon earlier in April after Netflix earnings disappointed investors. With little visibility over how higher interest rates will filter through the wider economy, money managers say trading has been thin and prone to whipsaw moves in both directions.

“Nothing goes down in a straight line and nothing goes up in a straight line,” said Michael Antonelli, managing director and market strategist at Baird. “You don’t need a lot to move the stock market when everyone’s this pessimistic.”

Friday may bring a quick reversal to the tech sector’s gains if after-market trading is any indication. Shares of Amazon. com fell 7.3% in late trading after the company posted its first quarterly loss since 2015 as sales growth slowed significantly. Intel’s stock similarly fell, down 4.1% after hours as the company reported a decrease in quarterly earnings and lower demand for personal computers.

Apple shares edged up 2% after hours. The iPhone maker posted stronger-than-expected earnings and revenue, and Chief Executive Tim Cook said supply constraints were lower than the December quarter.

While Thursday’s gains for Meta’s stock and tech more broadly were substantial, they pale in comparison to earlier-year losses. Meta’s stock remains down roughly 39% so far this year, and the tech sector in the S&P 500 is off nearly 15% from where it closed out 2021. In this month alone, inflation fears, worries about profit growth and turmoil overseas sent stocks tumbling.

Volatility in the stock market hasn’t sustained at such a high level since the 2008 financial crisis, with the exception of the start of the pandemic, said John Roe,

head of multiasset funds at Legal & General Investment Management. Bond volatility is the highest since the financial crisis outright, he added.

“I don’t think people have a lot of conviction at all,” he said. “It’s a period of time when fundamental uncertainty is at a particularly high level.”

The U.S. corporate world is in the throes of earnings season, and while profits and losses are moving individual stocks, analysts and traders say they are more concerned about the tenor of executives on earnings calls.

“What I want to hear in earnings reports is not whether you met or exceeded expectations, but what you see in the future,” said Kristina Hooper, chief global market strategist at Invesco. She said so far this earnings season, executive commentary paints a picture that the challenges corporations face may be prolonged. 

In individual stock moves Thursday, Twitter shares rose 47 cents, or 1%, to $49.11 after the social-media company posted higher revenue and withdrew financial guidance ahead of its acquisition by Elon Musk.

Southwest Airlines rose 96 cents, or 2.1%, to $46.90 on forecasts that the airline will turn a profit for the rest of the year.

Caterpillar shares fell $1.52, or 0.7%, to $212.44 after the industrial bellwether said margins fell in the first quarter. McDonald’s said profits were higher than analysts had expected, pushing shares up $7.05, or 2.9%, to $254.19.

On the economic front, data showed the U.S. economy shrank at a 1.4% annual rate in the first quarter, its first contraction since the pandemic. Though the rate of decline is worrisome, some analysts said they aren’t anticipating a recession given the underlying data. A big driver in the decline was a widening trade deficit, meaning the U.S. imported far more than it exported. Consumer spending also rose during the period, a slight acceleration from the end of last year.

The data could also play a role in the Federal Reserve’s decision on whether and by how much to raise rates at its next meeting, scheduled for next week.

Investors will get a glimpse of how decades-high inflation—and the Fed’s response—are affecting consumer sentiment when Apple and Amazon file quarterly results after the closing bell.

Overseas markets rallied. The Stoxx Europe 600 rose 0.6% on strong earnings reports.

Traders worked on the floor of the New York Stock Exchange on Wednesday.

Photo: justin lane/Shutterstock

Chinese markets regained their footing after tumbling on concerns that lockdowns in major cities would slow growth in the world’s second-largest economy. The Shanghai Composite Index edged up 0.6%. Hong Kong’s Hang Seng rose 1.7%.

The Nikkei 225 gained 1.7% after the Bank of Japan reinforced its commitment to low interest rates despite rising inflation. The central bank said it would purchase 10-year Japanese government bonds at a yield of 0.25% every business day to ensure that the yield doesn’t exceed that level.

The commitment to easy monetary policy contrasts with the stance of the Fed, and sent the yen lower against the dollar. Japan’s currency tumbled to about 130.65 yen per dollar, the weakest level since 2002. The offshore yuan weakened about 0.9%, with one dollar buying about 6.64 yuan.

The WSJ Dollar Index rose 0.8% to 95.94, near its highest since March 2020, when the early spread of Covid-19 was causing stress across global markets.

Write to Joe Wallace at joe.wallace@wsj.com and Quentin Webb at quentin.webb@wsj.com