U.S. stocks overcame steep losses Monday but the Dow industrials and S&P 500 still closed lower as investors reassessed the prospects for President Donald Trump’s ambitious economic agenda after a Republican plan to repeal and replace Obamacare was scrapped last week.

The Dow Jones Industrial Average DJIA, -0.87% marked its longest losing streak since August 2011 with eight straight declines, closing down 45.74 points Monday, or 0.2%, at 20,550.98, after overcoming an earlier 184-point deficit. The blue-chip average was led lower by shares of Chevron Corp. CVX, -0.73% and Goldman Sachs Group Inc. GS, +0.01%

Read:These 5 charts show how Trump’s health-care flop is hitting markets

The S&P 500 SPX, -1.11% slid 2.39 points, or 0.1%, to close at 2,341.59, as seven out of 11 sectors finished lower. Telecom and financial shares led decliners, while health-care and materials stocks led advancers. The benchmark index has finished down seven out of the past eight sessions. Earlier in the session, the equity gauge had been down by as many as 22 points.

The Nasdaq Composite Index COMP, -1.07% closed up 11.64 points, or 0.2%, at 5,840.37, overcoming an earlier 59-point deficit.

The failure of the health-care bill, Trump’s first major legislative test as president, raised questions about his ability to push bills through Congress, as well as the unity of the Republican coalition. Markets have rallied since the election on the hope that Trump’s economic proposals — including on taxes and regulation — would accelerate economic growth, and those gains could be at risk if no legislation materializes, especially with stock valuations at lofty levels.

Read:The Trump tax-cut trade was already leaking air, chart shows

Despite the health-care defeat and what that might presage for the rest of Trump’s agenda, the strong economic backdrop that has also figured into the rise of stocks since the election hasn’t changed, said Bill Stone, chief investment strategist at PNC Asset Management Group, in an interview. Stone pointed to strong price manufacturing index data from not just the U.S. but Europe as signs of an improving economy.

“Fundamentals are strengthening, the problem is we can’t say how much [of the market rise] was about taxes,” Stone said.

“We’ve gone a long time without a 5% pullback, but with the economic backdrop I think people are buying before we go 10% down,” Stone said. The Dow is currently 2.9% off its recent record high, with the S&P 500 off 2.5%, and the Nasdaq off 1.5%.

“Financial markets seem increasingly skeptical that Trump will be able to deliver on the many promises that fueled the S&P 500 [to] a peak of close to 2,400 in early March. This will place the emphasis on the economic data, at least until the next debate in Washington is more advanced,” said Michala Marcussen, global head of economics at Société Générale, in a note to clients.

Check out:‘Trump disappointment trade is now in full swing’ — analysts on the selloff

Major indexes closed mostly weaker on Friday, posting the biggest weekly losses in months after Trump and Republican leaders pulled their health-care bill from a vote.

How the GOP health-care bill failed

Need to know: Get ready to move from ‘buy the dip’ to ‘sell the rip’

Economic docket: There were no top-tier data on the economic calendar Monday, but a few Federal Reserve speakers were on tap.

Chicago Fed President Charles Evans said Monday that the central bank could raise rates four times this year if the economy “really takes off,” while Dallas Fed President Rob Kaplan is scheduled to discuss economic conditions and the role of monetary policy at Texas A&M University at 6:30 p.m. Eastern.

See:The U.S. economy doing OK even if official figures show a low score

Stocks to watch:Snap Inc. SNAP, -1.97% rose 4.8% after RBC analysts initiated shares at overweight, with a $31-per-share price target. Meanwhile, J.P. Morgan initiated the Snapchat parent at neutral with a $24 price target.

United Airlines UAL, -3.61% shares rose 0.7%, recovering after the airline was in focus after a social-media storm over the airline stopping two girls wearing leggings from boarding a flight.

Apple Inc. AAPL, -3.17% ticked up 0.2% after a Chinese court overturned a ruling against the company over iPhone patents, a win for the tech giant in one of its toughest markets.

Other markets: European stocks SXXP, -0.66% finished lower, tracking the global equity pullback, led by weakness for banks.

Read:Wall Street fear threatens a dramatic comeback in the stock market

Asian stocks finished mostly lower, with the Nikkei 225 index NIK, +0.17% closing down 1.4%. That came as the Japanese yen, which tends to attract buyers in times of economic and political uncertainty, surged against rivals. The dollar USDJPY, -0.15% hit its lowest level against the yen during Asian trade since the November election.

Meanwhile, gold US:GCJ7, another haven asset, settled up 0.6% at $1,255.70 an ounce. WTI oil futures US:CLK7 settled down 0.5% at $47.73 a barrel.

— Barbara Kollmeyer in Madrid contributed to this report.