By Akane Otani

U.S. stocks ripped higher after expectations-defying data showed the country added 2.5 million jobs in May, boosting investors' bets on a nascent, if likely uneven economic recovery.

Investors have been betting that the country will be able to both contain the spread of the coronavirus and reopen businesses in the coming months. Many are pricing in a "V-shaped" recovery: a sharp upturn in spending and growth that follows a short, painful collapse in economic activity.

Friday's jobs report appeared to be the clearest indication yet that the economy may be able to pull out of its downturn faster than investors had expected.

The Labor Department said the U.S. added 2.5 million jobs in May -- a stunning gain, given economists surveyed by The Wall Street Journal had expected a loss of 8.3 million jobs. The unemployment rate also unexpectedly fell, clocking in at 13%, compared with estimates of 20%.

There are some caveats to the data. Economists note that multitrillion-dollar government aid programs will begin to run out this summer, potentially leaving small businesses in a lurch. And experts believe that there could potentially be a second wave of coronavirus cases, especially after thousands of Americans around the country turned out to protest against the May 25 killing of George Floyd.

But for many on Wall Street, the jobs report appeared to at least temporarily validate the stock market's rally over the past few months.

"Something like this builds credibility for what the stock market has been telling you," said Brian Belski, chief investment strategist for BMO Capital Markets. "There's a massive amount of negativity among macro analysts. But the proof is in the pudding."

The Dow Jones Industrial Average climbed 829 points, or 3.2%, to 27111 as of the 4 p.m. ET close of trading. The S&P 500 advanced 2.6% and the Nasdaq Composite climbed 2.1%, ending just shy of a fresh closing high.

The moves put all three indexes further into positive territory for the week. They also extended a stock recovery that has allowed major indexes to chip away at much of the losses they incurred after the coronavirus pandemic brought business and spending around the country to a halt.

Shares of cyclical companies, whose profits are closely tied to the economy's trajectory, helped lead Friday's stock rally.

Heavy machinery manufacturer Caterpillar jumped 4.9% in afternoon trading, while aerospace giant Boeing rose 15%.

Bank stocks also posted big gains, with Bank of America up 6.2% and Goldman Sachs Group rising 2.7%. Bank stocks tend to pick up when investors expect economic conditions will improve, boosting lending activity.

In another mark of optimism, gold prices dropped 2.5% for their biggest one-day slide since March. Investors tend to buy the precious metal to hedge against anticipations of market turmoil.

Despite Friday's surge, some analysts urge caution.

The economic recovery taking place in some parts of the world is still in its early stages, and also hinges on governments not having to reimpose lockdowns should there be another spike in coronavirus cases.

Further government intervention might be needed to support businesses if activity doesn't rebound by the third quarter, said Daryl Liew, chief investment officer at REYL Singapore.

Earnings are also expected to deteriorate sharply. S&P 500 companies are expected to report earnings contracting 43% in the second quarter, the largest year-over-year decline since the last three months of 2008, according to FactSet.

While many investors believe much of the slide in economic activity has been priced in, others believe stocks' recent run has been overdone.

Sixty-seven percent of investors surveyed by Strategas Securities believe the S&P 500's next 10% move will be to the downside.

Elsewhere Friday, the Stoxx Europe 600 benchmark rose 2.5%. The European Central Bank has scaled up its bond-buying program, while Germany has adopted its second economic-stimulus package since the start of the coronavirus pandemic.

"It's a step in the right direction from the European leaders and shows some unity," said Brian O'Reilly, head of market strategy for Mediolanum International Funds. Rising bond yields can help boost profitability for banks, which borrow short-term to lend long-term.

In Asia, Hong Kong's Hang Seng benchmark rose 1.7% and South Korea's Kospi rallied 1.4%.

Michael Wursthorn, Avantika Chilkoti and Joanne Chiu contributed to this article

Write to Akane Otani at akane.otani@wsj.com