S&P 500 Soars 13% in 2012, Logs Best Gain in 3 Years

Stocks finished the final trading day of 2012 with a sharp rally, snapping a five-day losing streak, as optimistic remarks from Senate minority leader Mitch McConnell and President Barack Obama overshadowed the possibility that the U.S. could go over the "fiscal cliff" at the end of the night.

Note: U.S. stock-market futures are closed Tuesday due to the New Year's holiday and will re-open at 6am ET Wednesday, according to the CME website.

The House was not expected to vote on any measure tonight, meaning the U.S. could go over the fiscal cliff at midnight, sources told CNBC in the final minutes of trading. Still, major averages shrugged off the news and finished near session highs. (Read More: Going Over the 'Cliff,' but Tax Agreement 'in Sight')

The stock market will be closed Tuesday for New Year's day.

S&P 500

The Dow Jones Industrial Average soared 166.03 points, or 1.28 percent, to close at 13104.14, led by Hewlett-Packard and Caterpillar, snapping a five-day losing streak. All 30 Dow components ended in positive territory.

The S&P 500 rallied 23.76 points, or 1.69 percent, to finish at 1,426.19. The Nasdaq surged 59.20 points, or 2 percent, to end at 3,019.51. The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, plunged below 18 after closing above 22 last week for the first time since June.

Despite recent pullbacks and choppiness amid the fiscal cliff concerns, equities turned in healthy gains for 2012. The Dow jumped 7.26 percent, the S&P 500 bounced 13.41 percent, and the Nasdaq advanced 15.91 percent. By comparison, stocks ended 2011 almost exactly where they began the year.

Among the key S&P sectors, financials posted the biggest gain, surging more than 26 percent in 2012. Bank of America was the top gainer on the Dow, skyrocketing an impressive 108 percent for the year.

Meanwhile, utilities finished in the red for the year, declining nearly 3 percent.

"We are very, very close" to coming up with a deal to prevent tax hikes, said McConnell, adding that talks with Vice President Joe Biden have been "successful." (CNBC SPECIAL REPORT: Will we go over the "fiscal cliff?" Tune in to CNBC TV today at 6pm ET.)

Earlier in the afternoon, President Obama said a deal to avoid a middle class tax hike was "in sight," though more work needed to be done before the midnight deadline to avoid the fiscal cliff.

While midnight on Monday marks the deadline for a deal, the government can pass legislation in 2013 that retroactively prevents the U.S. from going over the fiscal cliff, an option that is viewed as politically easier. Investors have remained relatively sanguine about the process, believing it will eventually be solved.

"The final hours of negotiations may appear like a tug-of-war between opposing teams with moments of progress offset by disappointing setbacks," wrote Gary Thayer, chief macro strategist at Wells Fargo Advisors. "[But] the country is likely to avoid the worst-case scenario…because both parties recognize that the worst-case scenario would most likely lead to a recession."

Facebook rallied after BMO Capital, known for bearish comments on the social-networking company, turned bullish on the stock. BMO upgraded the stock to "buy" from "sell" and boosted the price target to $32 from $15.

Apple jumped the lead the Nasdaq 100 gainers. Despite a rocky quarter, the iPhone maker closed up more than 30 percent for the year. (Read More: Apple Poised to Soar in 2013?)

Coal and iron-ore producer Cliffs Natural jumped to lead the S&P 500 gainers, lifted by a robust Chinese manufacturing report.

Duff & Phelps surged after the investment-banking company agreed to be bought by private-equity firm Carlyle Group for about $665 million.

Pulte Group and Sprint Nextel were the best performers on the S&P 500 this year, skyrocketing 187 percent and 142 percent, respectively. On the flip side, Apollo Group and AMD were the worst performers on the index, plunging 61 percent and 56 percent, respectively.

European markets ended narrowly mixed in a shortened session, although trading was muted as markets in Germany, Switzerland, Italy, Denmark, Norway, and Sweden were closed.

—By CNBC's JeeYeon Park (Follow JeeYeon on Twitter: @JeeYeonParkCNBC)

Coming Up This Week:

TUESDAY: New Year's Day -- Markets Closed
WEDNESDAY: Weekly mortgage applications, PMI manufacturing index, ISM mfg index, construction spending
THURSDAY: Challenger job-cut report, ADP employment report, jobless claims, FOMC minutes, Fed balance sheet/money supply, chain store sales, auto sales; Earnings from Family Dollar
FRIDAY: Employment situation, factory orders, ISM non-mfg index, oil inventories, Fed's Yellen speaks; Earnings from Mosaic

More From CNBC.com: