Wall Street clawed back the last of the historic, frenzied losses unleashed by the new coronavirus, as the S&P 500 closed at an all-time high Tuesday.

The day’s move was a relatively mild one, nudging the index up 7.79 points, or 0.2%, to 3,389.78. That eclipses the S&P 500′s previous record closing high of 3,386.15, which was set Feb. 19, before the pandemic shut down businesses around the world and knocked economies into their worst recessions in decades.

The S&P 500′s milestone caps a furious, 51.5% rally that began in late March. The index, which is the benchmark for many stock funds at the heart of 401(k) plans, is now up nearly 5% for the year.

The stock market’s sprint back to an all-time high also means that the gut-wrenching, nearly 34% plunge for the S&P 500 from Feb. 19 through March 23 was the quickest bear market on record. It lasted barely more than a month. Compare that with the 19.6 months that it’s taken the average bear market to find its bottom, according to S&P Dow Jones Indices.

Tremendous amounts of aid from the Federal Reserve and Congress helped launch the rally, which built higher on signs of budding growth in the economy. More recently, corporate profit reports that weren’t as bad as expected have helped boost stock prices.

The market spent the past few days within striking distance of a new high, but falling short of the milestone, until the last minutes of trading Tuesday.

The Dow Jones Industrial Average fell 66.84 points, or 0.2%, to 27,778.07. It remains 6% below its record set in February. The Nasdaq composite had already returned to a record, thanks to huge gains for the big tech stocks that dominate it. It hit a new one Tuesday, climbing 81.12 points, or 0.7%, to 11,210.84.

The lightning recovery is even more remarkable considering how much the economy is still struggling and how uncertain the path ahead remains. Millions of Americans are continuing to get unemployment benefits, and businesses across the country are still shutting their doors. COVID-19 continues to seep throughout the world, with more than 5.4 million known cases and 170,000 deaths in the United States alone.

Many investors acknowledge the disconnect between the stock market and the broader economy, but they say the rally has been built on top of several supports.

Key among them is that the Federal Reserve and Congress have plowed trillions of dollars into the economy, to keep it from plunging even more deeply and to prevent a full-blown financial crisis. Their unprecedented moves helped halt the S&P 500’s free-fall in March.

More recently, the stock market’s rally has morphed from relief that the worst-case scenario of a full-blown financial crisis is off the table to hopes that the economy is on the mend. As widespread lockdowns of businesses have eased since the spring, data from across the economy have been showing improvements.

A report last week said 963,000 U.S. workers filed for unemployment benefits, for example. It’s a sickeningly high number, but it’s also the first time the tally has dropped below 1 million since March. With such budding economic improvements in hand, investors are looking further into the future and betting on one where corporate profits can broadly bloom again after a vaccine for COVID-19 hits the market later this year or in 2021.

The five biggest companies in the S&P 500 by market value, meanwhile, have continued to pile up blowout profits, even as earnings crater for the rest of the market. These Big Tech companies increasingly drive the S&P 500’s movements almost by themselves, and they’ve benefited from the pandemic because it accelerated work-from-home and other tech trends. Apple, Microsoft, Amazon, Facebook and Google’s parent company are all are up more than TK% for 2020 so far.

The market’s huge gains have been slowing in recent weeks, and many investors say the easiest gains have been made. But optimism remains strong across much of Wall Street. At Goldman Sachs, strategist David Kostin raised his year-end forecast for the S&P 500 to 3,600 from an earlier outlook for 3,000. Prospects for a vaccine played a big role in the upgrade.

At the same time, though, many risks are still hanging over the market.

Investors are still waiting to see if Congress and the White House can get past their partisan differences and agree on more aid for the economy. Without the stimulus, analysts say the economy won’t be able to make the recovery that investors have been assuming is on the way. And that assumption is a huge reason the stock market is as high as it is.

Rising tensions between the United States and China, meanwhile, threatens trade between the world’s two largest economies. Techstocks have had a few stumbles recently amid worries that China could retaliate against U.S. moves by targeting U.S. chip makers and others.

Perhaps the biggest threat of all is if a vaccine for COVID-19 fails come to the market as quickly as markets are expecting. That could quickly take a chunk back out of the market’s huge rally.

For now, though, the market’s momentum remains on a gentle upward slope. Even Treasury yields have recently been making a move higher, though their ascent slowed on Tuesday.

The yield on the 10-year Treasury dipped to 0.67% from 0.69% late Monday. In March, the yield had touched its record low just beneath 0.34%.

Higher yields can be an indication that investors are upgrading their expectations for inflation and the economy. But they can also pull some buyers away from stocks into bonds, hurting stock prices in the process.

“It’s important to recognize that the bond market doesn’t seem to trust this rally,” said Brian Price, head of investment management for Commonwealth Financial Network.