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 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.

Talking Numbers: Best Dow Stocks Next Year

The "Dogs of the Dow" strategy holds that the worst Dow stocks will be the next year's stars. Carter Worth, Oppenheimer, and Jeff Tomasulo, Belpointe Alternatives, discuss.

"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."

What You Need to Know About 2013

With less than 20 minutes to go in the last trading session of 2012, what do you need to know about 2013? John Manley, Wells Fargo Advantage Funds and Chris Konstantinos, Riverfront Investment Group, discuss.

Facebookrallied 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.

Applejumped 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?)

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 AMDwere 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.