U.S. stocks ended a tumultuous year with the Dow Jones industrial average and the S&P 500 at record highs, as the three major U.S. equity indexes notched solid-to-spectacular yearly gains despite an economy upended by the COVID-19 virus.

At the close of a year that marked the end of the longest bull market on record as pandemic-induced government lockdowns battered the global economy, investors looked to a post-pandemic world. Equities stormed back, with the S&P 500 climbing more than 66% from its March 23 low, resulting in the shortest bear market in history.

The gains were fueled in part by massive fiscal and monetary stimulus put in place to buttress the economy reeling from the coronavirus fallout, as well as progress on a vaccine.

For the year, the S&P 500 gained about 16%, the Dow roughly 7% and the Nasdaq more than 43%, which marked the biggest yearly gain for the tech-heavy index since 2009.

"For broad indexes, this is a bullish year despite the craziness in the real world," said Mike Zigmont, head of research and trading at Harvest Volatility Management.

"It feels very much to me like investors have decided the world has changed forever, the coronavirus pandemic was the catalyst and now investors have decided who the winners are and who the losers are and are moving forward."

Recovery path awaits

Still, data on Thursday were a reminder the economy still has a lengthy recovery ahead as weekly initial jobless claims, while declining for a second straight week to 787,000, remained well above the peak of the 2007-09 Great Recession.

Tech and consumer discretionary were the best performing sectors on the year, while energy, a laggard for the past decade, was again the weakest of the 11 major S&P sectors on the year en route to its worst yearly performance ever.

Mega-cap companies such as Amazon and Apple helped lift the broad S&P 500 and the Nasdaq, as well as gains in names that have benefited from the "stay-at-home" environment, such as online retailer ETSY Inc. and digital payment platform PayPal.

For the session unofficially, the Dow rose 191.34 points, or 0.63%, to 30,600.9; the S&P 500 gained 24.37 points, or 0.65%, to 3,756.41; and the Nasdaq Composite added 23.03 points, or 0.18%, to 12,893.03.

Near-term expectations of bigger stimulus checks dimmed after Senate Majority Leader Mitch McConnell blocked a quick vote on Wednesday to back President Donald Trump's call to increase COVID-19 relief checks to $2,000 from $600.

Risk assets were able to build on the rally off the March low, adding to gains in November following a U.S. election that investors viewed as likely to result in political gridlock, plus optimism about vaccine approvals. But the momentum stalled on worries about fresh fiscal stimulus and a new, highly infectious COVID-19 variant spreading globally.