McAuliffe received 47 percent to Cuccinelli's 46 percent, with 97 precincts reporting.
McAuliffe, a Democrat, ran strong among unmarried women, voters who made abortion a top issue and those who called the suburbs of Washington, D.C., home, according to preliminary results of an exit poll conducted for The Associated Press and the television networks. Cuccinelli, meanwhile, fared well among tea party backers, gun owners and among the state's rural residents - but there were not enough of them to yield a victory.
In winning, McAuliffe broke a stubborn streak in state history. During the past nine governor's races, the party that controlled the White House at the time has always lost.
That's not to say voters rushed to back McAuliffe's vision for Virginia. Turnout for was low, and both candidates worked through Election Day to reach as many potential voters as possible.
Only 52 percent of voters said they strongly backed their candidate, the rest had reservations or backed a candidate because they disliked the other options, according to exit polls. Neither major candidate's ideological views seemed "right" for a majority of Virginians, 50 percent called Cuccinelli too conservative, 41 percent said McAuliffe is too liberal.
The exit poll included interviews with 2,376 voters from 40 polling places around the state. The margin of error was plus or minus 3 percentage points.
Voters' dissatisfaction couldn't overshadow the fight on television. McAuliffe enjoyed a 10-to-1 advertising advantage over Cuccinelli during the final days.
"We were very heavily outspent but I'm proud we ran on first principles," Cuccinelli told supporters in conceding. "The battle goes on."
The campaign's tilt turned many voters off.
"I really hated the negative campaigning," said Ellen Tolton, a 52-year-old grant writer. "I didn't want to vote for any of them."
Richard Powell, a 60-year-old retired IT manager who lives in Norfolk, described himself as an independent who frequently votes for members of both parties. He said he cast his ballot for McAuliffe, although not because he's particularly enthusiastic about him. He said he was more determined not to vote for Cuccinelli, who he said overreaches on a variety of medical issues.
Voters were barraged with a series of commercials that tied Cuccinelli to restricting abortions, and while Powell said the negative advertising "got to be sickening," abortion rights played a factor in his vote.
"I'm not in favor of abortion - let's put it that way - but I find that restricting abortion causes far more social harm than allowing abortion, so that was an issue for me," he said.
McAuliffe's narrow victory in Virginia rested on a 9-point edge among women, while the two major party candidates split men about evenly, according to exit polls. McAuliffe carried liberals and moderates, Cuccinelli independents and tea party backers.
Libertarian Robert Sarvis spiked to 15 percent support among voters younger than 30, and independents.
From the outset, the campaign shaped up as a barometer of voters' moods and a test of whether a swing-voting state like Virginia would elect a tea party-style governor. Republicans bet a deeply conservative candidate would be their best shot at holding onto the governor's office, passing over a lieutenant governor for Cuccinelli, a crusader against the federal health care law.
McAuliffe, who once led the Democratic National Committee and is a confidant of former President Bill Clinton and Hillary Rodham Clinton, said he would expand Medicaid to provide health coverage for 400,000 people under the federal health care law. By contrast, Cuccinelli, the current attorney general, vehemently opposed the law and was the first to challenge it in court.
Cuccinelli pinned his hopes on voters' frustrations with the federal health care law he attempted to foil. He tried to make the election into a referendum on the health care law, which McAuliffe supports. The 45-year-old Cuccinelli went into Election Day trying to overcome a deficit in the polls, a crush of negative ads and a lingering wariness among fellow Republicans about his conservative views.
Some Republicans switched allegiances for the election and others sided with Sarvis.
Sharon Ann Ross, a 56-year-old landscape designer, said her vote for McAuliffe in Manassas was in keeping with a gradual shift in her politics. She used to favor Republicans, but now she supports Democrats.
"I'm kind of embarrassed to be a Republican," said Ross, a gun owner who favors conservatives on Second Amendment issues but said the economy drove her decision.
"Right now, I feel more comfortable voting through my wallet," she said. "I'd like to better my life, and I think a Democratic ticket does more for average people like me."
As one of just two races for governor nationwide, political strategists eyed the race for clues about what would work - and what would not - for 2014's midterm elections when control of Congress is up for grabs.
The 56-year-old McAuliffe succeeds term-limited Gov. Bob McDonnell, a Republican, for a four-year term starting in January.___
Associated Press Writer Brock Vergakis contributed to this report from Norfolk and Virginia Beach, Va. Associated Press writers Ben Nukols in Manassas and Steve Szkotak in Richmond also contributed.