By Caitlin McCabe and Caitlin Ostroff

U.S. stocks tumbled Wednesday in a choppy trading session as investors weighed a rise in coronavirus infections against signs that the economy is recovering.

The Dow Jones Industrial Average and the S&P 500 swung between gains and losses for much of the day, before their declines accelerated heading into the closing bell. Both indexed snapped a three-day winning streak.

The Dow dropped 170.37 points, or 0.6% to 26119.61, dragged down by everything from Boeing to Exxon Mobil to JPMorgan Chase. The S&P 500 lost 11.25 points, or 0.4% to 3113.49.

Meanwhile, the Nasdaq Composite extended its winning streak to a fourth day thanks to a rally in technology stocks. It gained 14.66 points, or 0.1% to 9910.53, its fourth-highest close in history.

Traders have been weighing in recent weeks varying signals about economic reopenings, coronavirus infections and potential new stimulus measures to try to determine where indexes may be headed next. Last week, a punishing selloff offered traders a wake-up call, but stocks nevertheless continued to rise in the following days. Tuesday's data showing a rebound in retail sales helped fuel the climb.

But promising housing-market data wasn't enough to keep the rally going Wednesday. Permits authorizing residential construction rose 14.4% in May to a seasonally adjusted annual rate of 1.22 million units -- outpacing expectations.

Meanwhile, housing starts, a measure of new-home construction, climbed 4.3% in May, though they fell short of the jump that economists expected to see.

"We're taking a bit of a breath," said David Bahnsen, chief investment officer of The Bahnsen Group, a wealth-management firm, of Wednesday's stock market performance. "That's probably a pretty healthy thing."

Investors have been hyper-focused lately on comments from Federal Reserve Chairman Jerome Powell and any new actions by the Fed. Mr. Powell has recently warned that the economy faces potentially significant long-term damage.

In his Wednesday testimony before the House Financial Services Committee, Mr. Powell said it would "be a concern if Congress were to pull back from the support that it's providing too quickly." Congress faces deadlines this summer over how to address expiring relief measures for workers and businesses.

U.S. stocks turned positive for much of Mr. Powell's testimony before ultimately tumbling again. Cruise lines, energy companies, banks and airlines were among the stocks that were hard-hit by the end of the day.

Norwegian Cruise Line Holdings fell 8.4% after it said that it would suspend the majority of its voyages through Sept. 30. Meanwhile, United Airlines Holdings slid 2.4%, Wells Fargo fell 3.8% and Marathon Oil sank 5.5%.

In contrast, large-cap technology companies were a bright spot. Netflix gained 2.7% and Amazon added 1%.

Home-improvement retailers and some home builders also ticked up. Lowe's added 3% and Home Depot rose 0.4%. Home builder D.R. Horton increased 0.9%.

The choppiness of Wednesday's session underscores how some investors are still taking a cautious approach as they track coronavirus cases. The total number of infections in the U.S. has surpassed 2.13 million, making up more than a quarter of global confirmed cases. This week, Texas, Arizona and North Carolina reported record daily virus-related hospitalizations.

"Certainly the next phase is not going to be as straightforward or as easy as the leg we've just had" with the stock market's rally, said Derek Halpenny, head of research for global markets in the European region for MUFG Bank. "Now the equity market is going to be a bit more unpredictable."

The yield on the 10-year Treasury fell Wednesday to 0.732%, from 0.754% Tuesday. Yields fall when bond prices rise.

Globally, the pan-continental Stoxx Europe 600 added 0.7%. In Asia, most major equity benchmarks drifted higher, though some markets were turbulent as investors assessed growing geopolitical risks in the region. North Korea this week blew up an inter-Korean liaison office, marking Pyongyang's resumption of a provocative stance while denuclearization talks with Washington remain gridlocked.

The benchmark indexes in South Korea and China ticked up 0.1%, while Hong Kong's Hang Seng Index ended the day up 0.6%

And the Nikkei 225 fell 0.6% after trade data showed Japan's exports slumped.

Write to Caitlin McCabe at caitlin.mccabe@wsj.com and Caitlin Ostroff at caitlin.ostroff@wsj.com