By Karen Langley and Anna Hirtenstein

The S&P 500 retreated Tuesday, pausing a powerful rally that had briefly returned the broad U.S. stock index to positive territory for the year.

Major U.S. indexes have surged more than 40% from their March lows as investors have grown optimistic about how the economy will recover from the coronavirus-sparked downturn.

"After a rally like we saw yesterday, the temptation is to take profits, " said Luca Paolini, chief strategist at Pictet Asset Management. "There's no shame to neutralize your position and take a pause. The outlook for the global economy is very, very challenging."

A day after a sharp rally pushed S&P 500 into positive territory for the year, the index fell 25.21 points, or 0.8% to 3207.18. The Dow Jones Industrial Average lost 300.14 points, or 1.1%, to 27272.30, snapping a six-day winning streak. The indexes are off 0.7% and 4.4%, respectively, in 2020.

Technology stocks were a bright spot Tuesday. The Nasdaq Composite clinched a second consecutive record, after eclipsing on Monday its high from before the selloff. The tech-heavy index added 29.01 points, or 0.3%, to 9953.75.

"Tech is reasserting itself today as that market leader," said Matt Miskin, co-chief investment strategist at John Hancock Investment Management. "That's what's been one of the key elements, looking at this market rally, is that when one side of the market takes a break, the other one comes back, and vice versa."

Beaten-down value and cyclical stocks have led the market higher in recent weeks.

Most sectors of the S&P 500 lost ground, while the communication services and technology groups -- among the best performers this year -- edged higher. Shares of small companies, which are considered sensitive to the strength of the economy, halted their recent rally, with the Russell 2000 index sliding 1.9%.

Airline stocks also pulled back after a multiday rally. Shares of American Airlines Group declined $1.76, or 8.7%, to $18.55. Delta Air Lines shares fell $2.80, or 7.6%, to $34.17. United Airlines Holdings shares dropped $4.05, or 8.3%, to $44.64.

The coronavirus and efforts to control its spread have had a severe effect on the economy. The U.S. officially entered a recession in February, according to the National Bureau of Economic Research, marking the end of a 128-month expansion.

The future course of the pandemic remains unclear. More than a dozen U.S. states have seen confirmed coronavirus cases increase in the past week at a pace faster than in the week prior, according to a Wall Street Journal analysis of Johns Hopkins data.

"There are questions that still remain," said Luc Filip, head of discretionary portfolio management at SYZ Private Banking. "Will there be a second wave of virus outbreak? Will we have a lot of defaults and bankruptcies? Will this recovery be as strong as expected in the second half of the year?"

There are signs investors see more volatility on the horizon. A measure of turbulence in American equities, the Cboe Volatility Index, climbed to its highest since June 1.

Corporate earnings, meanwhile, are expected to decline sharply in the second quarter. In the months to come, investors will watch for companies to offer guidance about their future performance.

"Right now the markets seem to be running on euphoria because of what the central banks have done, low interest rates, the fact that we're starting to see some positive momentum out of the reopenings," said Megan Horneman, director of portfolio strategy at Verdence Capital Advisors. "Going forward, we need to see that translate into earnings growth."

The yield on the 10-year U.S. Treasury note ticked down to 0.829%, from 0.883% on Monday. Yields fall as bond prices rise.

The gradual recovery of major economies and the massive stimulus rolled out by the Federal Reserve has created an "almost perfect" scenario for risky assets like stocks, according to Paul Chew, head of research at Phillip Securities in Singapore.

"With the yield for 10-year Treasury bonds at less than 1%, there isn't much intrinsic value for investors," he said. Investors' appetite for risk will continue to rise as new coronavirus cases in large economies trend downward and more countries reopen, he added.

The drop in U.S. stocks Tuesday followed declines overseas. The pan-continental Stoxx Europe 600 fell 1.2%. Japan's Nikkei 225 retreated 0.4%, though other Asian indexes ended the day higher.

Chong Koh Ping contributed to this story.

Write to Karen Langley at karen.langley@wsj.com and Anna Hirtenstein at anna.hirtenstein@wsj.com

Corrections & Amplifications

This item was corrected at 6:39 p.m. ET to show that the Cboe Volatility Index climbed to its highest since June 1. An earlier version incorrectly reported that it was the highest level since May.