The Standard & Poor's 500 index notched its best year since 1997; The Dow Jones industrial average rose the most since 1995.
While trading was light on the last day of the year, investors were able to rally behind a report that showed U.S. consumer confidence improved significantly in December.
The early signs for the stock market in 2014 are also encouraging.
"I expect a lot of good things for the new year," Karyn Cavanaugh, market strategist with ING U.S. Investment Management, said. "The economy is getting better and corporate earnings are improving. That's going to drive the market higher next year as well."
On Tuesday the Standard & Poor's 500 rose 7.29 points, or 0.4 percent, to 1,848.36. The index ended 2013 up 29.6 percent. With dividends included, the total return was 31.9 percent.
The Dow Jones industrial average rose 72.37 points, or 0.4 percent, to 16,576.66. The blue chips ended the year up 26.5 percent.
Lastly, the Nasdaq composite rose 22.39 points, or 0.5 percent, to close out 2013 at 4,176.59. The Nasdaq did far better than the Dow and S&P, rising 38.3 percent for the year.
While stocks clawed higher for most of 2013, the rally accelerated into the end of the year. The Federal Reserve's announcement on Dec. 18 that it would start paring back, or "tapering," its economic stimulus pushed stocks further into record territory.
"Since the Fed announced it was tapering its stimulus program two weeks ago, investors that were underinvested in stocks have pulled out of gold and bonds and moved it into stocks," said J.J. Kinahan, chief strategist with TD Ameritrade. "It's been a quiet rally."
All 10 sectors of the S&P 500 ended the year higher, but the year's biggest gainers were companies most exposed to the U.S. economic recovery. Consumer discretionary stocks in the S&P 500 rose 40 percent this year. Close behind were industrial stocks with a gain of 37 percent.
As it has been for the last two weeks of the year, trading volume was very low Tuesday. Roughly 2.3 billion shares were traded on the New York Stock Exchange, about 40 percent below average. Most investors closed their books before the week of Christmas.
2013's rally took many investors by surprise.
Any number of things could have derailed the market's rally: The U.S. government shutdown, the possibility of a default, the threat of military action in Syria, budget cuts and new worries about European government debt. Instead, the market just kept on going.
Skittish investors who jumped out of stocks this year not only lost out, but were punished for it.
Bond investors lost money this year, according to Barclays Capital U.S. Aggregate Bond Index, a broad measure of the debt market. The index fell 2 percent this year, the first decline since 1999.
If bond investors had a disappointing year, gold investors got slammed. Gold lost 28 percent of its value in 2013, its worst year since 1981.
With the U.S. economy improving and stocks performing so well, gold is likely to remain under pressure, Kinahan said.
U.S. financial markets will be closed on Wednesday for New Year's Day.
AP Markets Writer Steve Rothwell contributed to this report.