By Anna Hirtenstein and Ben Eisen

The S&P 500 and Nasdaq Composite rose to fresh highs Tuesday after manufacturing data showed the economy continues to bounce back from the coronavirus shutdown.

U.S. manufacturing activity accelerated in August, growing for the third straight month and topping the expectations of economists, according to data from the Institute for Supply Management. The growth was driven by new demand and faster export orders, though the picture for hiring was mixed, a pair of surveys released Tuesday showed.

"The continuation of this recovery is being priced in already," said Esty Dwek, head of global market strategy at Natixis Investment Managers. "As long as it keeps going, I think markets can continue advancing."

The S&P 500 climbed 26.34 points, or 0.8%, to 3526.65, opening September with a new record after its best August since 1986. The Nasdaq Composite rose 164.21 points, or 1.4%, to 11939.67, the technology-heavy index's 42nd record close of 2020. The Dow Jones Industrial Average rose 215.61 points, or 0.8%, to 28645.66, just over 3% away from February's record.

The economic rebound has some investors preparing for a more normalized investing environment that could favor beaten-down sectors like transports.

Brian Barish, chief investment office at Cambiar Investors, said his firm has been taking profits on some holdings of highflying tech companies, including Amazon.com and Google parent Alphabet. Both have marked sharp gains in recent months, making their shares look expensive to some.

"We are in spectacular valuation territory," Mr. Barish said. He is considering investing in hospitality companies, which stand to gain as the economy reopens.

Some of Tuesday's biggest gainers included retailers. Walmart rose $8.74, or 6.3%, to $147.59 ahead of the launch of Walmart+, a $98-a-year membership that includes free grocery delivery, a discount on gas from Walmart parking lots and the ability to check out via a mobile phone in stores. L Brands climbed $2.14, or 7.3%, to $31.54.

Technology companies also helped lead the S&P 500 higher, with Netflix climbing $26.99, or 5.1%, to $556.55.

Zoom Video Communications jumped 41%, or $132.59, to $457.69 after the video-chatting software developer raised its outlook for the year for the second time in recent months.

Data out from parts of Asia and Europe showed that factories are slowly recovering from the sharp output cuts that accompanied coronavirus lockdowns, but have continued to pare jobs in the face of an uncertain outlook.

Germany, Europe's industrial powerhouse, recorded a stronger recovery, with the purchasing managers index rising to the highest level in almost two years. But even with a revival in previously weak export orders, manufacturers reported that they were cutting jobs.

The pan-continental Stoxx Europe 600 fell 0.3%.

A gauge of China's manufacturing activity for last month rose to its highest level in nearly a decade, supported by strong domestic and external demand and faster production activity. It marked the fourth consecutive month that the Caixin China purchasing managers index held above 50, the mark separating contraction from expansion. The Shanghai Composite Index ended the day up 0.4%.

The dollar weakened early in the session amid expectations that U.S. interest rates will remain low for an extended period, though it recovered losses throughout the day.

Federal Reserve official Richard Clarida's comments Monday that employing yield curve control was a future possibility, and that a low unemployment rate won't be a sufficient trigger to raise interest rates, had weighed on the currency.

"While confidence can be taken from the rapid recovery in the manufacturing sector, it's all about dollar weakness currently and this will be the driving factor for a further rally," said Sam Cooper, a vice president of market risk solutions at SVB Financial Group.

In bond markets, the yield on 10-year Treasurys fell to 0.672% from 0.695% on Monday.

Gold rose early Tuesday, but gave back much of its gains throughout the session. It ended slightly higher at $1,968.20 a troy ounce. Its recent gains have been partly due to the weaker dollar as the precious metal is priced in the greenback, according to Stephane Monier, chief investment officer at Lombard Odier.

"The price of gold is also to a large extent a sign of confidence of investors into the financial systems," he said. "Some people are worried that central banks are printing a lot of money and want a refuge."

Lombard Odier, a Swiss private banking group, has added gold to its strategic asset allocation over the summer. The metal currently makes up 3% of holdings across client portfolios, Mr. Monier said.

Write to Anna Hirtenstein at anna.hirtenstein@wsj.com and Ben Eisen at ben.eisen@wsj.com