Updated

Democrat Terry McAuliffe won the Virginia governor’s race on Tuesday, in a surprisingly close victory over Republican rival Ken Cuccinelli -- who was heavily outspent and trailed in the polls for much of the race.

With nearly all precincts reporting, McAuliffe was ahead with just 48 percent of the vote, to Cuccinelli’s 45 percent. Though McAuliffe previously held a double-digit lead, exit polls showed voters opposed to the federal health care law overwhelmingly backed Cuccinelli, helping him narrow the gap on Tuesday.

"Despite being outspent by an unprecedented $15 million, this race came down to the wire because of ObamaCare," Cuccinelli said in his concession speech. "That message will go out to the entire country tonight."

"I know this has been a hard fought race," said McAuliffe in a victory speech that included a call for bipartisanship. "While the attorney general and I had a lot of differences, he is a principled man who spent a lot of time away from his family. I thank Ken Cuccinelli for his service to Virginia."

McAuliffe vowed to reach out to state Republican lawmakers and continue the efforts of outgoing GOP Virginia Gov. Bob McDonnell and previous governors to create jobs and improve transportation

More On This...

    McAuliffe -- the prolific Clinton family fundraiser and former Democratic National Committee chairman – brought the firepower of his party establishment connections to the closely watched race. He hauled in $34.4 million in campaign contributions, roughly $14 million more than Cuccinelli, including $8.1 million in the final month.

    McAuliffe’s victory could have ramifications in the 2016 presidential race, especially if Hillary Clinton runs, because it gives her an influential ally in a key swing state.

    But whether it serves as a bellwether for Democrats’ popularity in 2014 remains unclear. That McAuliffe’s lead narrowed in the final days -- due in part, it appears, to voters’ early dissatisfaction with ObamaCare -- could throw a scare into some Democrats up for re-election in red states in 2014.

    McAuliffe called upon the Clintons and President Obama to join him in Virginia in the closing weeks to help him close a campaign marked for its negative attacks, including ads that hammered Cuccinelli for his anti-abortion policies.

    McAuliffe also got a boost from the partial government shutdown, which helped him open up a double-digit lead over Cuccinelli in public polling.

    However, Cuccinelli managed to narrow the margin in recent days as he sought the make the election a referendum on the botched rollout of ObamaCare.

    "I'm scared to death about what ObamaCare is doing to Virginians, and Terry McAuliffe is scared to death what ObamaCare is doing to Terry McAuliffe,” Cuccinelli, who has tried to make the election into a referendum on the law that McAuliffe supports, repeatedly said.

    McAuliffe fared well among women voters and in the Washington, D.C., suburbs in Northern Virginia, according to early exit polls.

    Libertarian candidate Robert Sarvis was projected to finish a distant third, though he was garnering a fair amount of votes from young people.

    “ObamaCare has been a big part of why this race is a horse race at this point,” Cuccinelli said after casting his vote Tuesday morning.

    Cuccinelli, the state’s attorney general, made several final-hour campaign stops in hopes his conservative supporters would give him a come-from-behind win.

    He told reporters after voting in Northern Virginia that a strong GOP turnout would be “absolutely critical.”

    Turnout was expected to be low -- 40 percent was the figure both sides were using. And both candidates were mustering their campaign organizations to find every last supporter. The negative tilt of the campaigns turned many voters off, and strategists in both parties predicted the outcome would be decided by just a few thousand votes.

    McAuliffe, flush with cash, bombarded voters with a series of commercials that attempted to tie Cuccinelli to restricting abortions.

    Cuccinelli also got help from marquee Republicans, including visits from Louisiana Gov. Bobby Jindal and Sens. Marco Rubio, of Florida, and Rand Paul, of Kentucky -- all potential presidential contenders in 2016.

    The 56-year-old McAuliffe succeeds term-limited Gov. Bob McDonnell, a Republican, for a four-year term starting in January. He is now the state’s 72nd governor.

    Obama won the state in 2008 and 2012.

    Republicans bet a deeply conservative candidate would be their best shot, passing over a lieutenant governor for Cuccinelli, an early crusader against ObamaCare.

    The Associated Press contributed to this report.