Traders wear 2013 New Year's glasses while they work on the floor of the New York Stock Exchange on Monday in New York City. / Allison Joyce, Getty Images

by Adam Shell, USA TODAY

by Adam Shell, USA TODAY

NEW YORK - Despite a year rife with uncertainty due to the nation's fiscal crisis, U.S. elections and concerns about the global economy, the broad U.S. stock market performed surprisingly well, posting double-digit gains in 2012.

Stocks rallied 1.7% on the final trading day of the year amid signs that Democratic and Republican lawmakers were closing in on an 11th-hour deal to avoid the bulk of the so-called "fiscal cliff," propelling stocks to a 2012 gain of 13.4%.

The 13.4% gain in the benchmark Standard and Poor's 500-stock index came despite a late-year swoon that was caused by fears that lawmakers would not seal a deal by midnight to avoid economy-damaging tax hikes and government spending cuts, better known as the fiscal cliff.

All of the major U.S. stock indexes finished 2012 solidly in positive territory, successfully climbing what Wall Street dubs the "wall of worry" in the process. The biggest winner was the technology-dominated Nasdaq composite, which gained 15.9%. The Russell 2000, an index of small-company stocks, rallied 14.6%. The S&P 500, a large-company stock gauge, was next with a gain of more than 13%. The worst performer of the four major indexes was the blue-chip Dow Jones industrial average, which rose 7.3%.

Most likely, 2012 will be best remembered on Wall Street for the record run-up and subsequent 30% plunge of shares of Apple: the world's most-valuable company; the botched and overhyped Facebook IPO in May that saddled millions of Main Street investors with losses; a multibillion-dollar trading loss at JPMorgan Chase caused by a U.K. trader known as the "London Whale" whose big risks went bad; the first real signs of a sustainable recovery in the U.S. housing market, which catapulted home builder Pulte to a 188% gain and the No. 1 performing stock in the S&P 500; a repeat win for President Obama and a status-quo result in Congress on Election Day that all but assures more political gridlock on Capitol Hill; a bold, game-changing move by the European Central Bank to keep the eurozone from breaking apart; China's ability to avert a steep economic dive; and, of course, the late-year political battle in Washington, D.C., over how best to solve the nation's deepening fiscal crisis.

Yet, 2012 was also a year when investors became familiar with a new term or investing concept - "risk on" or "risk off" - to describe the up, down, up, down roller coaster known as the stock market. The market's moves in 2012 were increasingly determined by news headlines that caused investors en masse to either swing for the fences or play it super-safe. The year will also be remembered for the Facebook IPO, a losing experience for most that reminded investors that no investment is a sure thing.

And 2012 will also be remembered as the year when the economy started to show signs that it could start growing again at a more normal rate, witnessed by growth of 3.1% in the third quarter of 2012, its fastest pace since the final three months of 2011 and its second-best quarter of growth since 2009.

Stocks also got a boost from an improvement in the jobs market. In November, the unemployment rate dropped to 7.7%, far below its 10% peak in October '09 and its lowest level since December 2008. The Federal Reserve also provided a floor of sorts under stocks. The Fed, led by Chairman Ben Bernanke, reiterated its plans to keep short-term interest rates low until the the job market strengthened significantly. It also launched a fresh round of purchases of U.S. Treasury bonds and mortgage-backed bonds, an unconventional policy known as quantitative easing which it launched four years ago, in an effort to keep borrowing costs low to support economic growth and hiring.

But when you add up all the tail winds and subtract out all the headwinds in 2012, the stock market's gains added up to a paper gain of roughly $2.1 trillion for investors, according to Wilshire Associates.