(AP) -- Stocks capped a quiet day of trading with modest losses Friday, even as Wall Street closed the books on another banner year.
The S&P 500 finished with a gain of 26.9% for the year, or a total return of about 29%, including dividends. That's nearly as much as the benchmark index gained in 2019. The Nasdaq composite, powered by Big Tech stocks, climbed 21.4% in 2021. The Dow Jones Industrial Average gained 18.7%, with Home Depot and Microsoft leading the way.
"It's the third year in a row of incredible gains," said J.J. Kinahan, chief strategist with TD Ameritrade. "The market itself was just amazingly strong."
A wave of consumer demand fueled by the reopening of economies pumped up corporate profits more than expected in 2021, which helped keep investors in a buying mood. The Federal Reserve and other central banks also helped prop up the market by keeping interest rates extremely low, which makes borrowing money more affordable for both companies as well as consumers.
There was also intense interest in so-called "meme stocks," in which large groups of individual investors bought up shares of beaten-down companies like GameStop and AMC Entertainment, causing institutional investors like hedge funds to lose billions.
Along the way, the S&P 500 set 70 all-time highs, its most recent one on Wednesday. In the post-World War II era, that's the most new highs for the index since the 77 it set in 1954.
The market kept setting new highs despite plenty of challenges, including rising inflation, global supply chain disruptions and outbreaks of more contagious variants of the COVID-19 virus.
"Although there are a lot of things that people were nervous about all year and continue to be nervous about as we head to '22, at the end of the day the U.S. (stock) market still seems to be the best game in town," Kinahan said.
Still, the fast-spreading omicron variant and the looming end of the Federal Reserve's easy-money policies in 2022 are overhangs for investors going into the new year.
Trading was very slow Friday, with most of Wall Street on vacation and many fund managers already closed out of their positions for 2021.
The major indexes spent much of the day flipping between small gains and losses. The S&P 500 fell 12.55 points, or 0.3%, to 4,766.18. The Dow slid 59.78 points, or 0.2%, to 36,338.30. The Nasdaq fell 96.59 points, or 0.6%, to 15,644.97.
The Russell 2000 index of smaller companies slipped 3.48 points, or 0.2%, to 2,245.31. The index ended the year with a gain of 13.7%.
The yield on the 10-year Treasury note held steady at 1.51% after the bond market closed at 2:00 p.m. Eastern ahead of the New Year's Day holiday.