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

The Facebook owner’s stock rose 18% 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 2.9% and boosted the S&P 500 technology sector, the best performing group in the index in midday trading. The next big earnings test comes after the closing bell, when Apple and Amazon. com report their quarterly results.

The S&P 500 climbed more than 2.4% in afternoon trading, while the Dow Jones Industrial Average jumped 619 points, or 1.9%. In the bond market, the yield on 10-year Treasury notes ticked up to 2.875% 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% to $107.04 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.”

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 more than 40% so far this year, and the tech sector in the S&P 500 is off nearly 17% from where it closed out 2021. In this month alone, inflation fears, worries about profit growth and turmoil overseas sent stocks tumbling. The S&P 500 is down 7.7% through Wednesday’s close, on track for its worst April since 1970, according to Dow Jones Market Data Group.

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 1.9% after the social-media company posted higher revenue and withdrew financial guidance ahead of its acquisition by Elon Musk. Southwest Airlines rose 0.7% on forecasts that the airline will turn a profit for the rest of the year.

Caterpillar shares fell 2.8% after the industrial bellwether said margins fell in the first quarter. McDonald’s

said profits were higher than analysts had expected, pushing shares up 3.4%.

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.

In commodities, European natural-gas markets calmed after prices shot up when Russia turned off supplies to two European Union members Wednesday. Prices for gas futures fell 7.7% to 99.15 euros, equivalent to $103.96, a megawatt-hour.

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