U.S. stocks wavered Tuesday but were on track to end the month higher as major indexes wrapped up trading for August.

The S&P 500 wobbled between small gains and losses and recently hugged the flatline, a day after the broad index notched its 53rd record close of the year. The Dow Jones Industrial Average gained about 35 points, or 0.1%. The technology-heavy Nasdaq Composite slid 0.1%.

All three indexes are on track to notch monthly gains. The S&P 500 is up about 3.1% for August, putting it on pace for its seventh consecutive monthly win. The gains mark its longest winning streak since January 2018, when the index rose for 10 straight months.

The Dow has added 1.4% month-to-date, marking its second consecutive monthly win. The Nasdaq is up about 4% for the month, its third consecutive month of gains.

Stocks have spent most of August largely drifting higher, buoyed by strong second-quarter earnings results, thin trading volumes and ongoing accommodative monetary policy. Federal Reserve Chairman Jerome Powell reiterated Friday that while the central bank is expected to begin reducing its bond purchases later this year, the timing of that taper won’t have any bearing on subsequent decisions to raise interest rates from near zero. His comments about inflation—which Mr. Powell still views as a temporary surge—provided investors with further reassurance as concerns about pricing pressures have percolated for much of this year.

“The fact that the Fed is willing to start to taper in the face of this Delta variant coming through does suggest they have confidence that the economy is going to stand on its own two feet,” said Peter Langas, chief portfolio strategist at Bessemer Trust.

Still, the Delta variant of the coronavirus does present a potential headwind for stocks, particularly if consumer spending retreats or if new restrictions are imposed. Fresh data Tuesday showed that consumer confidence in the U.S. deteriorated in August, retreating to its lowest level since February. The Conference Board’s consumer confidence index fell to 113.8, from a downwardly revised 125.1 in July.

“You have seen people canceling vacations or not going out to restaurants” due to the Delta variant, said Mr. Langas. “There is this concern on the margin that we are seeing people pull back a bit. All of that comes into play in regards to where consumer confidence is going in the short term,” he said.

The yield on the benchmark 10-Year U.S. Treasury note edged up to 1.299%, from 1.284% on Monday. Bond yields and prices move in opposite directions.

Brent crude, the international benchmark in energy markets, fell 0.3% to $72.04 a barrel.

A trader on the floor of the New York Stock Exchange on Friday.

Photo: brendan mcdermid/Reuters

Among the S&P 500’s 11 sectors, financial stocks posted the strongest performance of the day. Shares of some technology companies, in contrast, pulled back after the group helped power the market higher Monday. Chip-makers including Nvidia and Advanced Micro Devices pulled back 1% and 0.6%, respectively. Apple lost 0.7%.

Zoom Video Communications fell 16%, on pace for its largest percentage decrease since November. On Monday, the video conferencing company’s adjusted earnings guidance came in lower-than-expected. Though second-quarter revenue surpassed $1 billion for the first time in the company’s history, Zoom officials said some metrics that had benefited from the pandemic had begun to normalize.

Meanwhile, shares of Support.com retreated 12%, pulling back after surging 38% Monday. Its shares have rocketed in the last week as individual investors have piled in and tried to execute a short squeeze on the stock.

Overseas, the Stoxx Europe 600 slid 0.5%. Japan’s Nikkei 225 rose 1.1%. In Hong Kong, the Hang Seng Index gained 1.3%, while China’s Shanghai Composite Index added 0.5%.

Write to Caitlin McCabe at caitlin.mccabe@wsj.com and Will Horner at William.Horner@wsj.com