U.S. stocks collapsed Wednesday, with the Dow Jones industrial average nearly erasing all of its gains since President Donald Trump took office as coronavirus anxiety gripped financial markets.

The Dow tumbled more than 1,300 points to close at 19,898.92, marking the first time the blue-chip average has closed below 20,000 since Feb. 2, 2017.

The Standard & Poor’s 500 sank 5.2% to finish at 2,398.10. Wednesday's losses briefly triggered an automatic shock absorber for 15 minutes in afternoon trading, the fourth time in eight trading sessions that circuit breakers were set off.

Both averages have nearly erased all of their gains since President Donald Trump's inauguration. The Dow is up less than 1% since then. The broader S&P 500 index had soared roughly 50% in that span when it hit records in mid-February and is now up just 6%.

Global markets have seen a wave of unprecedented volatility in recent weeks as investors grapple with border closures that have caused transportation chaos and imperiled economies. The border between Canada and the U.S. will close for non-essential travel, Trump confirmed Wednesday.

Investors have grown fearful as Wall Street and the White House acknowledge the rising likelihood that the outbreak will cause a recession.

"Worldwide panic is setting in," says John Spensieri, head of U.S. equities trading at Stifel. "The number of infections are growing, businesses are shutting down and schools across the country are closed. The reality is this will definitely hurt small businesses and hourly wage earners. The totality of everything is just too much for the market to bear all at once.”

Mortgage rates:A 'traffic jam' hits home refinancing as owners rush to take advantage of record-low rates

Auto loans:An economic slowdown could spell trouble for the rising number of people behind on car payments

Investors need to see the number of infections slow before markets can find a bottom, analysts say. The number of new cases reported in China, where the virus emerged in December, is declining but infections in the United States, Europe and elsewhere are increasing.

“There’s no clarity. We don’t know what the real effects from these monetary and fiscal policies are going to be for a while,” says Rich Sega, global chief investment strategist at asset manager Conning. “We need to see data that shows that the infection rate has peaked."

The S&P 500 has either lost or gained at least 4% over the past eight trading sessions through Wednesday, topping a previous record of six days set during the stock market crash in 1929, according to LPL Financial.

Wednesday’s selling swept markets around the world. Benchmark U.S. oil plunged 24% to settle at $20.37 per barrel, its third -worst day ever.

Stocks had stabilized a day earlier after Trump promised aid to get the U.S. economy through the pandemic.

The Senate approved a multibillion-dollar emergency aid package Wednesday that will provide paid sick and family leave for many Americans while also offering free testing for the coronavirus and bolstering unemployment insurance. The bill will now be sent to the White House for President Trump’s signature.

The Federal Reserve, meanwhile, has announced more measures to keep financial markets operating. The central bank said late Tuesday it would revive its crisis-era Primary Dealer Credit Facility that allows large financial institutions access to short-term loans.

Treasury Secretary Steven Mnuchin said Trump wants to send checks to Americans in the next two weeks to help support them while more parts of the economy come closer to shutting down.

“The monetary policy from the Fed can help us climb out of this later down the road, but White House officials still don’t have clarity on how long this will last,” Sega says. “That’s damaging markets. We don’t get the feeling that they know when this will be over.”

There were 115 reported deaths and more than 7,300 confirmed cases in the U.S. as of Wednesday afternoon, according to the Johns Hopkins University data dashboard. Worldwide, the virus has infected more than 200,000 people and killed more than 8,000.

Stocks have wiped out trillions in market value over the past month. The S&P 500 has shed nearly 30% since setting a record in mid-February, snapping the longest-ever bull market in Wall Street history.

No escaping a recession

"This is a severe blow to investor confidence and a severe blow to household net worth," says Doug Ramsey, chief investment officer at the Leuthold Group. "We're certainly not going to escape a recession. Now the question is how deep?"

A global recession is Morgan Stanley's “base case,” with growth expected to fall to 0.9% this year, analysts said in a note. Global growth is forecast to contract 0.3% in the first quarter and 0.6% in the second quarter, they said. A “strong monetary and fiscal policy response” from the U.S. government is expected to help revive global growth in the third quarter.

In Europe, the FTSE 100 in London dropped 4.2% and Frankfurt’s DAX skidded 5.2%. France’s CAC 40 shed 5.4%. In Asia, the Shanghai Composite Index fell 1.8% and the Nikkei 225 in Tokyo shed 1.7%. Hong Kong’s Hang Seng skidded 4.2%.

Contributing: The Associated Press