Stocks post biggest 1-year gain since 2013

The Nasdaq and S&P 500 rose 35.2% and 28.9%, respectively, for the year.

The tech-heavy Nasdaq and the benchmark S&P 500 rose 35.2% and 28.9%, respectively, for the year, marking their biggest annual gains since 2013. The Dow climbed 22.3%, its best year since 2017.

The indexes spent most of the last trading session of the year wavering between gains and losses but ended in positive territory. The Dow closed at 28,538.44, up 0.27% on the day, while the S&P closed at 3,230.78, up 0.29%. The Nasdaq rose 0.3% to close at 8,972.60.

The S&P 500, which includes many of the biggest American companies, has had a total return of about 257%, or about 13.6% annually, since the beginning of the decade, Howard Silverblatt, a senior index analyst at the S&P Dow Jones Indices, wrote on Twitter. That's higher than the average annual total return, including dividends, of about 10.3% since the 1920s, he said.

Those calculations did not include figures at Tuesday's close.

ABC News' Zunaira Zaki contributed to this report.