The Dow Jones Industrial Average and the S&P 500 rose Thursday, helping both benchmarks close in on fresh records, despite new data suggesting the economic recovery has started to slow.

The gains followed data showing gross domestic product grew by 6.5% on an annualized basis in the second quarter, up slightly from earlier in the year but well below analyst’s forecasts of 8.4% growth. Meanwhile, jobless claims, a proxy for layoffs, came in at 400,000, resuming their downward trajectory but also coming in above projections.

Investors shrugged off the economic misses though.

Matt Peron, director of research at asset management firm Janus Henderson Investors, said that data deep in the GDP report, such as consumer spending, was strong, suggesting the economic recovery remains intact despite recent concerns about the Delta variant of Covid-19.

“Consumer spending surged, while the negatives in the report were from inventory drawdown, presumably from supply shortages,” said Mr. Peron. “This implies that the economy, and hence earnings which have also been very strong so far for 2Q, will continue for some time.”

Many investors seemed to agree with the take. The Dow rose more than 200 points in recent trading, while the S&P 500 added 0.6%. Both are on pace to close at their highest levels ever and snap two-day losing streaks, some of which was brought on by concerns of a Covid-19 resurgence. The Nasdaq Composite also rose, gaining 0.3%.

The deeper dive into the data also lent further credence to the Federal Reserve’s position, affirmed just a day earlier, that the economy has further room to run before easing accommodative fiscal policies. Although Chairman Jerome Powell did hint that the Fed may taper bond-buying programs this year.

On Thursday, 10 of the 11 major sectors of the S&P 500 rose, with financial firms, energy companies and manufacturers among the biggest gainers. Some of the gains were due to the release of upbeat corporate earnings.

Shares of Ford rose 3.8% after the car maker posted a surprise profit and raised its outlook for the year. Qualcomm also topped analysts’ projections, sending shares of the tech firm up 5.6%.

“Most companies are in a pretty positive situation. They have cash, they have demand. It’s something that was a bit expected already from last quarter, but we’re still having positive surprises,” said Ludovic Subran, chief economist at Allianz.

Meanwhile, communication stocks lagged, dragged down by some lackluster quarterly results.

Facebook shares fell 4.1% after the social media platform said it expected revenue growth to slow in the second half of the year. PayPal slid 5.5% after reporting a drop in profit in the second quarter.

Thursday’s other big movers included Nikola, which shed nearly 10% after Trevor Milton, the founder of and one-time executive chairman of the electric-truck startup, was charged Thursday with making misleading and false statements to the company’s investors. Uber also fell 2.2% on a report that SoftBank plans to sell about a third of its stake in the company

And popular investing platform Robinhood began trading on the Nasdaq Thursday after pricing its IPO at $38 a share, at the bottom of its expected range. Shares dipped in their debut, recently trading at about $36 apiece.

In Asia, most major benchmarks rose. The Shanghai Composite Index climbed 1.5% and Hong Kong’s Hang Seng Index added 3.3%, led by advances in technology stocks. The Chinese government sought to reassure global banks and investors about the recent volatility in markets, saying that Beijing would consider the market impact of future policies.

That helped some U.S.-listed Chinese tech stocks recover from recent losses, while Ride-hailing giant Didi Global soared 12%, as executives weigh going private, according to people familiar with the matter.

Elsewhere, the Stoxx Europe 600 advanced 0.5%.

Investors are digesting the latest communication from Federal Reserve Chairman Jerome Powell.

Investors are digesting the latest communication from Federal Reserve Chairman Jerome Powell.

Photo: Richard Drew/Associated Press

Write to Anna Hirtenstein at anna.hirtenstein@wsj.com and Michael Wursthorn at Michael.Wursthorn@wsj.com