New York CNN Business  — 

The Dow and the S&P 500 started and ended this unprecedented year at all-time highs — with a lot of volatility along the way.

All three major indexes ended Thursday, the final trading day of the year, higher. The Dow (INDU) closed 0.7%, or 197 points, higher, and the broader S&P 500 (SPX) rose 0.6%. The Nasdaq Composite (COMP) climbed 0.1%, falling just short of its Monday record.

“2020 is coming to an end,” wrote Paul Hickey, co-founder of Bespoke Investment Group, in a note to clients. “Unfortunately, 2021 is going to start out looking a lot like 2020, but hopefully, by the end of the year, it’s looking more like something better.”

While the economy is nowhere near its pre-pandemic strength, the stock market rally tells a different story. All three benchmarks ended the year with gains for a second year in a row.

The Dow climbed 7.3% this year, while the S&P rose 16.3%. For the Nasdaq, it was best year since 2009 with a 43.6% gain.

At the start of 2020, investors worried the market might have less tailwind as the Fed stopped cutting interest rates and the economic jolt from the Trump tax cuts ran out. On top of that, the US-China trade deal still hung in the balance. But little did they know they were about to fall off a cliff.

After hitting record highs at the start of the year, the market began to quiver in fear of the coronavirus pandemic in February and deepened its selloff in March as lockdown measures took hold across the Unites States. The Dow routinely set new records for its biggest one-day point drops in history, and the New York Stocks Exchange had to suspend trading in the S&P 500 multiple times because the index plummeted too fast.

Meanwhile, worried investors snapped up every 10-year US Treasury bond they could find in an effort to safeguard their investments, driving the bond’s yield below 1% for the first time in history in March.

But in the months that followed, as the economic pain from the pandemic continued, the stock market recovered faster than many expected.

Unprecedented intervention from the Federal Reserve, which slashed interest rates and launched a slew of lending facilities to backstop markets and the economy, helped a great deal with that.

Meanwhile, oil investors were shaken as the commodity sold off in April and the price US oil to be delivered in May turned negative as oversupply, storage concerns and worries about demand during the pandemic coincided.

“This year was a year with a lot of reminders for investors: number one, don’t overreact,” Leo Grohowski, chief investment officer at BNY Wealth Management, told CNN Business.

As the stock market roared back from its steep March losses, investors who had panicked and pulled their money lost out on the rally.

The length and strength of the stock market rally was one of the most surprising parts of the year for investors. People will look back at this year and wonder how such market records could have been reached against the backdrop of unprecedented economic hardship, said JJ Kinahan, chief strategist at TD Ameritrade.

The lesson: “Wall Street just isn’t reflecting main street,” Kinahan said. “But the other part of this is that there is also no main street stock market.”

Indeed,companies that ended up gaining market share during the pandemic, such as Amazon (AMZN) and Walmart (WMT), were already enormous businesses before Covid-19. Meanwhile, smaller businesses and mom-and-pop stores were, and still are, in a very different situation.

The US economy remains in deep trouble with millions unemployed and plenty businesses struggling. With the new stimulus bill signed into law last Sunday and more government aid expected in the new year, there is plenty to be optimistic about for 2021. President-elect Joe Biden’s administration plans to keep going to get the economy back on track, and that will help markets next year even if the excitement about them might begin to peter out, Kinahan said.