U.S. stocks rose Thursday after fresh data on the labor market and the trade balance showed that the economic recovery remains on track.

The Dow Jones Industrial Average rose 131.29 points, or 0.4%, to 35443.88 and the S&P 500 added 12.86 points, or 0.3%, to 4536.95, setting a fresh record high. The Nasdaq Composite, which also set a record on Wednesday, rose 21.80 points, or 0.1%, to 15331.18, as large technology stocks extended their gains.

Equities prices have remained on a steady upward march for nearly a year despite all the problems and uncertainty created by the coronavirus pandemic. The S&P 500 has risen 20% this year, up 40% from its 52-week low from last September, and hasn’t seen a single drop of 5% or more since last November.

The index rose every month between February and August, its longest such streak since 2018. It has set 53 record highs this year.

It has been a nice, steady summer for the index. From Memorial Day through Thursday, the S&P 500 rose about 2.3%, above the average gain of 1.3%.

History cautions against betting too heavily on the rally continuing. In years when the S&P 500 rose at least 20% through August, the index averaged a decline of 2% for the rest of the year, according to Dow Jones Market Data.

Where stocks go from here will be heavily dependent on the economy and the Federal Reserve. Jobless claims, a proxy for layoffs, dropped to 340,000, reaching a new pandemic low. The Fed signaled that the labor market’s recovery is a factor in its monetary policy decisions. Separately, new data showed that the U.S. trade deficit narrowed to $70.1 billion in July as American consumers shifted spending toward in-person services and away from goods.

The yield on the benchmark 10-year Treasury note ticked down to 1.293% from 1.301% on Wednesday.

Stocks have pushed higher this week as investors weighed strong corporate earnings and low interest rates against indicators that growth may be slowing in some parts of the world. Money managers say they are awaiting the jobs report for August, due Friday, for more cues on when and how the Fed may taper its bond purchases.

“The confluence of a strong recovery at the same time as very low interest rates and maybe the peak of policy accommodation: if you put those all together, it is a very powerful mix for risky assets,” said Bill Papadakis, macro economist at Lombard Odier. “If you consider the alternatives in which investors could put their money today—with interest rates where they are—equities are often the one option for somewhat better returns.”

On Wednesday, ADP said the private sector created only 374,000 jobs in August, below expectations. That could be a warning sign for Friday’s government jobs report. A weaker economy complicates the Fed’s timeline for raising rates, said Ava Trade analyst Naeem Aslam.

“Investors are considering bad news as good because the economy not recovering quickly may convince the Fed to stick to its soft-money stance,” he said.

One corner of the market that has cooled significantly are so-called SPAC stocks. A broad selloff has wiped about $75 billion off the value of companies that came public through special-purpose acquisition companies, according to a Dow Jones Market Data analysis of figures from SPAC Research.

Among corporate names, Spotify rose 6.6% to $254.03. Apple said it would allow media apps such as the music streaming service to link to their own websites for payment, taking down restrictions criticized as anticompetitive.

Oil prices rose a day after the Organization for Petroleum Exporting Countries and its Russia-led allies agreed to continue increasing oil production. U.S. crude gained 2% to $69.99, lifted by lower-than-expected inventories, according to analysts.

The price of bitcoin touched $50,000 on Thursday morning, after a strong run in August. But similar to the past week, it struggled to get over the mark, more recently trading at $49,300. Shares in cryptocurrency exchange Coinbase Global added 0.9% to $268.18.

Overseas, the pan-continental Stoxx Europe 600 added 0.3%. In Asia, most major benchmarks rose by the close of trading. The Shanghai Composite Index climbed 0.8% while Hong Kong’s Hang Seng Index added 0.2%.

Traders worked on the floor of the New York Stock Exchange in July.

Photo: Richard Drew/Associated Press

South Korea’s Kospi Index declined 1%. Stronger-than-expected inflation data may prompt an interest-rate increase in the coming months, according to analysts at Barclays.

Write to Anna Hirtenstein at anna.hirtenstein@wsj.com and Paul Vigna at paul.vigna@wsj.com