Lights for the holidays illuminate the New York Stock Exchange. / John Moore, Getty Images

by Adam Shell, USA TODAY

by Adam Shell, USA TODAY

NEW YORK - The stock market wrapped up its best year since 1997, showering investors with an almost 30% gain in a record-breaking run that might finally have convinced investors scared off by the 2008 financial crisis that stocks remain a viable investment alternative.

"It was a great year, one for the record books," says Alan Skrainka, chief investment officer at Cornerstone Wealth Management.

Nothing, it seemed, could slow the stock market's profitable run in 2013. The Boston Marathon terrorist bombing didn't dent investors' resolve. Nor did political turmoil in Egypt. Or a near U.S. military confrontation with Syria.

Similarly, a sharp spike in yields on U.S. government bonds and rising anxiety over an eventual shift to a less market-friendly Federal Reserve policy couldn't spark a stock market downturn, either. Investors also shrugged off electronic glitches at stock exchanges, ongoing economic worries, and a government shutdown.

The year "saw a downsizing of fear," says David Kelly, chief global strategist at J.P. Morgan Funds. "A lot of people's fears diminished, and that allowed money to come back into stocks."

Wall Street historians had a busy year as the record books had to be rewritten.

The 117-year-old Dow Jones industrial average, which was powered by the Fed's easy-money policies and an improving economy, notched 52 record closes, including closing on the last day of trading at a fresh all-time high of 16,576.66 on Tuesday. It is up 26.5%, its best annual performance since 1995.

The benchmark Standard & Poor's 500 index notched 45 new highs, and is up 29.6% at 1848.36, its best gain in 16 years. The Nasdaq composite performed like it did in the go-go 1990s, soaring 38.3% to 4176.59, a level not seen since September 2000.

The small-cap Russell 2000 also hit new-high territory in 2013, gaining 37% to 1,163.64. All told, the stock market has seen a paper gain of roughly $5.4 trillion, according to Wilshire Associates.

Along the way, stock investors got a few breaks.

To start the year, squabbling Democrats and Republicans signed off on an 11th-hour deal that helped the economy avert the worst of the "fiscal cliff," a mix of government spending cuts and tax hikes. And despite fears that the Fed would dial back on its market-friendly bond-buying stimulus program, the central bank held off and said it won't start phasing out its stimulus until January 2014, a delay that enabled the economy and job market to gain steam and U.S. companies to post record earnings.

The nation also averted war with Syria and sidestepped other geopolitical landmines in places such as Iran and Egypt.

With fears receding, investors gained confidence and bid up stock prices. They were willing to pay more for each dollar of a company's earnings, resulting in rapid price appreciation. A key valuation metric, the price-to-earnings ratio, or P-E, of the S&P 500 swelled from 14 times companies earnings over the past 12 months at the start of 2013 to nearly 17 times by year's end, according to Terry Sandven, chief equity strategist at U.S. Bank Wealth Management.

"We are ending 2013 in a good place," says Sandven. "The global economy is in slow-growth mode. Interest rates are low. Inflation is contained. And corporate earnings are rising. Typically, that presents a favorable environment for stocks."