By Anna Hirtenstein, Gunjan Banerji and Joanne Chiu

U.S. stocks rallied Tuesday on fresh data showing consumer spending rebounded in May after states began easing lockdown restrictions.

The S&P 500 gained 2.3%, heading toward a third consecutive session of gains. The Dow Jones Industrial Average climbed more than 600 points, or roughly 2.5%. The Nasdaq Composite added about 2%.

Retail sales rose 17.7% in May, according to data from the Commerce Department, marking a sharp bounceback from a record slump in March and April during the depths of the pandemic. May's jump was the biggest monthly increase in retail spending in records dating back to 1992.

It's the latest sign that the worst of the economic shock from the pandemic may have passed in March and April, when there were widespread shutdowns throughout the country. Employers also added more jobs than expected last month.

"It's a blowout number," said Sebastien Galy, a macro strategist at Nordea Asset Management. "This is a very sharp rebound and is very encouraging for the U.S. and the global economy as a whole. While we still might not see a V-shaped recovery, we're certainly moving away from a U-shaped one."

Gains in the stock market were broad, with all 11 of the S&P 500's groups rallying. The tech-heavy Nasdaq was on track for its third consecutive gain of 1% or more, the longest such streak since January 2019. The Russell 2000, which tracks smaller companies, is on track for its third straight rise of at least 2%, the longest such streak since 2010, according to Dow Jones Market Data.

Shares of retail giants were some of the biggest gainers. Shares of Kohl's added 8.2%. Nordstrom shares jumped 14.5%, while Gap stock soared 6.6%.

Investors so far have been quick to look past dour economic data and pounce on hints of a recovery that have emerged in recent weeks, though the outlook for the economy remains murky. Major U.S. indexes have rallied more than 35% from their lows in March, a speedy recovery that has defied expectations.

In early June, the latest jobs figures showed that the country added 2.5 million jobs in May, well above expectations and spurring a rally in the stock market.

"The market's still looking ahead -- past the current data, whether it's positive or negative," said John Zaller, chief investment officer at MAI Capital Management.

Parsing the fallout from a global pandemic has been challenging for economists and analysts, and some apprehension has emerged in recent days. U.S. stocks have logged some of the biggest swings in months as investors have weighed the uptick in cases and harsh reality of the downturn alongside the economic reopening across the country.

And some investors have been sitting on the sidelines of the market, flush with a record amount of cash.

"What makes it even more difficult now is the uncertainty around whether Covid-19 cases are going to stay at these fairly high levels," said Mr. Zaller. "That is something that is very hard to gauge."

On Tuesday, stocks pared much of their gains in early trading before turning higher again. Media reports said that coronavirus infection cases in Beijing are rising again. Recently, there have been increases in coronavirus cases in more than a dozen states.

On Monday, U.S. stocks staged a dramatic reversal as the Fed said it would broaden a program to purchase bonds of U.S. companies.

The market "is hypersensitive right now to any sort of negative news given how much of a bounceback we've had," said R.J. Grant, director of equity trading at KBW.

And many investors are wary that the U.S. economy could be scarred by the downturn for years to come. Federal Reserve Chairman Jerome Powell said in testimony presented to the Senate Banking Committee Tuesday that the economy faces significant long-term damage from higher unemployment, despite recent signs of improvement. He said a full economic recovery is unlikely "until the public is confident that the disease is contained."

The yield on the 10-year U.S. Treasury note, which is seen as a haven, rose to 0.753%, from 0.701% Monday. Yields rise as bond prices fall.

The pan-continental Stoxx Europe 600 advanced 2.9%.

In Asia, regional benchmarks rallied. South Korea's Kospi Composite gained 5.3% and Japan's Nikkei 225 climbed 4.9%. Benchmarks in Hong Kong and Shanghai also advanced. That tracked a dramatic reversal in the U.S. on Monday, where indexes swung from early losses to close solidly higher.

"A combination of monetary and fiscal policies from global governments, including those in the U.S. and Europe, is something that is supporting the equity markets," said Frank Benzimra, head of Asia equity strategy at Société Générale.

Write to Anna Hirtenstein at anna.hirtenstein@wsj.com, Gunjan Banerji at Gunjan.Banerji@wsj.com and Joanne Chiu at joanne.chiu@wsj.com