By Caitlin McCabe and Anna Hirtenstein

The S&P 500 broke a four-session winning streak Thursday in a volatile trading session that forced investors to weigh their optimism about the reopening of the economy against data that showed the pandemic's continued toll.

The index tumbled 10.52 points, or 0.3%, to finish the day at 3112.35. The Nasdaq Composite fell 67.10 points, or 0.7%, to end at 9615.81, pulled down by declines in shares of megacap technology companies.

The Dow Jones Industrial Average rose 11.93 points, or 0.05%, to end at 26281.82 on Thursday. Companies including Microsoft, UnitedHealth Group and Nike were among the stocks in the index that fell.

A 6.4% rally in heavyweight Boeing, meanwhile, helped mitigate the losses that the other indexes suffered.

Stocks have rallied for much of the week, despite the social unrest and widespread protests that have gripped the country since George Floyd, a black man, died after being restrained by Minneapolis police. Traders had instead focused on promising signs of an economic recovery, as well as optimism that global economies could see more stimulus measures.

Thursday's data on job losses and trade paused that rally, giving investors the chance to take profits after a dramatic stock rebound that kicked off in late March.

"There's a little bit of [questioning] of how far can this [rally] go?" said Brad McMillan, chief investment officer at Commonwealth Financial Network. "From a bearish perspective, there's still a lot to worry about."

"But from a bullish perspective, we do see the pandemic under control and no meaningful signs of a second wave yet," he continued. "A V-shaped recovery seems more possible than it was a week ago."

The S&P 500 and the Dow are on pace for their third consecutive week of gains, which would mark the longest weekly winning streak for the indexes this year. The S&P 500 has risen 2.2% week-to-date, cuttings its losses for the year to 3.7%.

Meanwhile, the Dow is up 3.5% for the week, on pace for its third weekly gain of more than 3%. The last time that happened was in July 1933.

Disappointing data released before the markets opened Thursday weighed on investor sentiment. The Commerce Department said the U.S. trade deficit widened in April as imports and exports both dropped sharply amid coronavirus-related shutdowns around the world. The foreign-trade gap in goods and services expanded 16.7% from the prior month to a seasonally adjusted $49.41 billion.

Meanwhile, the number of Americans drawing on unemployment benefits rose to 21.5 million in the week ended May 23, the Labor Department said. However, the pace of increase significantly slowed from earlier in the crisis.

Losses across stocks were broad, with eight of the S&P 500's 11 sectors posting declines. A rally continued in the financials, materials and industrials sectors -- all of which were hit hard at the beginning of the stocks selloff. American Airlines added 41%, its largest one-day percentage increase since December 2013 when American and US Airways Group merged.

Declines were broad across big technology companies, a group that has helped buoy the stock market off its late-March low. Netflix lost 1.8%, and Facebook fell 1.7%. Zoom Video Communications tumbled 6%.

In Treasury markets, the yield on the 10-year U.S. Treasury note jumped to 0.818%, from 0.761% Wednesday. Yields rise when bond prices fall.

Elsewhere, the pan-continental Stoxx Europe 600 fell 0.7% after the European Central Bank said it would scale up its bond-purchase program to EUR1.35 trillion ($1.52 trillion) through June 2021. The bank also left its key interest rate unchanged at minus 0.5%.

The eurozone economy has undergone an unprecedented sharp contraction as a result of the coronavirus pandemic and there are "exceptional" levels of uncertainty, ECB President Christine Lagarde said in a press conference.

"They've delivered what was wanted by the market," said Seema Shah, chief strategist at Principal Global Investors. "It's delivering what it needed to do" which was to extend its ammunition beyond the autumn, she said, referring to the bond-buying program.

In Asia, Hong Kong's Hang Seng Index ticked 0.2% higher, while the Shanghai Composite Index edged down 0.1%.

"There's a disconnect between equities and the economic fundamentals," said Alex Wong, a director at hedge fund Ample Capital, noting that he is holding more cash after gradually reducing investments in some richly valued new-economy stocks.

"Many investors are looking beyond short-term realities and banking on hopes of an economic recovery in 2021 as global economies gradually reopen," he said.

Joanne Chiu contributed to this article.

Write to Caitlin McCabe at caitlin.mccabe@wsj.com and Anna Hirtenstein at anna.hirtenstein@wsj.com

Corrections & Amplifications

This item was corrected at 9:09 p.m. ET to reflect that he Dow Jones Industrial Average rose 11.93 points, or 0.05%, to end at 26281.82 on Thursday. Companies including Microsoft, UnitedHealth Group and Nike were among the stocks in the index that fell. The original version incorrectly said that the three companies dragged the index lower in the third paragraph.