AP Business Writer
NEW YORK (AP) -- If you'd told investors what was going to happen in 2012 -- U.S. economic growth at stall speed, an intensifying European debt crisis, a slowdown in China, fiscal deadlock in Washington, decelerating corporate earnings growth -- and asked how the stock market would perform, few would have predicted a good year.
But that's just what they got.
The Dow Jones industrial average, the Standard & Poor's 500 and the Nasdaq composite index all ended the year substantially higher, despite losing ground in the final days of year as concerns about the looming "fiscal cliff" mounted.
The Dow gained 7 percent for the year, its fourth consecutive annual advance, having started the year at 12,217. The S&P 500, which started the year at 1,257, is up 13 percent, beating the 7.8 percent average annual gain of the past 20 years. The Nasdaq also logged a better-than-average gain, 16 percent.
Including dividends, the total return on the S&P 500 index was even better: 16 percent.
Financial companies led the gains among S&P 500 stocks, advancing 26 percent, as banks continued their restructuring efforts after the recession. Bank of America more than doubled, gaining $6.05 to $11.61 and Citigroup advanced $13.25, or 50 percent, to $39.56. Utilities, the best-performing industry group last year, was the only sector of 10 industry groups in the index to decline, dropping 2.9 percent.
"There's been a lot thrown at this market, and it's proven to be very resilient," said Gary Flam, a portfolio manager at Bel Air Investment Advisors in California. "Here we are at the end of the year, and it's still relatively strong."
Stocks started the year on a tear, with optimism about an improving job market and a broader economic recovery providing the backdrop to the S&P 500's best first-quarter rally in 14 years.
The index advanced 12 percent by the end of March, closing the quarter at 1,408, its highest in almost four years, with financial companies and technology firms leading the charge. The Dow ended the first quarter at 13,212, logging an 8 percent gain.
Apple was one of the star performers of the first quarter and was probably the year's most talked-about company.
The popularity of the iPhone and iPad led to staggering sales growth that helped push its stock up 48 percent to almost $600 at the end of March. Apple also announced a dividend and overtook Exxon Mobil as the U.S.'s most valuable company.
At the start of the second quarter, the intensifying European debt crisis and concerns about the impact that it would have on global economic growth prompted a sell-off.
By the start of June, U.S. stocks had given up the year's gains. Borrowing costs for Spain surged and investors fretted over the outcome of Greek elections that had the potential to pull the euro currency bloc apart.
The outlook for growth in China, the world's second-largest economy, also began to weigh on investors' minds. Economic growth there slowed to 8.1 percent in the first quarter as export demand waned, and investors worried that it would keep falling.
The Dow fell as low as 12,101 June 4. The S&P dropped to 1,278 June 1.
The second quarter was also marred by Facebook's initial public offering.
The stock sale was one of the most keenly anticipated initial public offerings in years, but investors didn't "like" the $16 billion market debut. The social network priced its IPO at $38 per share, and the stock started to fall soon after the first day of trading on concern about the company's mobile strategy.
Facebook closed as low as $17.73 on Sept. 4 before recovering some of the ground it lost to close the year at $26.62.
Company earnings reports were also starting to make uncomfortable reading for investors. Earnings growth for S&P 500 companies fell as low as 0.8 percent in the second quarter, according to S&P Capital IQ data.
The stock market only recovered its poise after the European Union put together loans to bail out Spain's banks on June 10 and the head of the European Central Bank, Mario Draghi, pledged to do "whatever it takes" to save the euro.
Speculation that the Federal Reserve was set to provide the economy with more stimulus to prevent it from slipping back into recession also bolstered stocks.
The rally even survived a blip when a software glitch at trading firm Knight Capital threw stock prices into chaos Aug. 1.
The firm said the problem was triggered by new trading software it installed. Erroneous orders were sent to 140 stocks listed on the New York Stock Exchange, causing sudden price swings and surging trading volume.