Wall Street pumped the brakes on its recent rally Tuesday, as a late slide in big technology companies left stocks broadly lower, erasing an early gain.

The reversal left the S&P 500 with a 0.8% loss after having been up 0.6% earlier. The decline in big-name technology stocks like Apple and Microsoft, plus losses in health care and communications stocks, outweighed gains in financial, industrial and energy companies. Tech stocks have far outpaced the rest of the market this year as investors bet they could still thrive in a stay-at-home economy.

The pullback ended the S&P 500’s seven-day winning streak. Despite the sell-off, the benchmark index remains within 2% of the all-time high it reached in February, reflecting a stunning turnaround from a nearly 34% tumble in March when the coronavirus pandemic sent stocks into a nose-dive.

Investors have grown more confident in recent weeks amid some positive economic data and better-than-expected second-quarter results from companies, suggesting corporate profits could be headed higher in the second half of this year and in 2021. Traders are also increasingly optimistic that the many pharmaceutical companies working on ways to treat COVID-19 will deliver a working vaccine in the coming months.

“What is a risk worth taking is the assumption that a vaccine will be made available around year-end, and that this vaccine will help eliminate the virus in the coming year,” said Sam Stovall, chief investment strategist at CFRA Research.

The S&P 500 fell 26.78 points to 3,333.69. The Dow Jones industrial average dropped 104.53 points, or 0.4%, to 27,686.91. The Nasdaq composite lost 185.53 points, or 1.7%, to 10,782.82. The Russell 2000 index of small-company stocks gave up 9.57 points, or 0.6%, to 1,575.10.

The price of oil closed lower after being up earlier. Benchmark U.S. crude oil for September delivery fell 0.8% to settle at $41.61 per barrel.