Democrat Terry McAuliffe will be Virginia’s next governor after defeating Virginia Attorney General Ken Cuccinelli (R) Tuesday. 

McAuliffe led Cuccinelli by 48 percent to 46 percent with 97 percent of precincts reporting. The Associated Press has called the race.

The win gives Democrats control of a governor’s mansion in a crucial swing state, and marks the first time in four decades that the party in control of the White House won Virginia’s gubernatorial race. 

McAuliffe, a close friend of the Clinton family and former Democratic National Committee chairman, used a significant fundraising advantage to attack Cuccinelli for his social conservatism and Tea Party ties. He has led in all polling of the race since July, though the final election results were considerably closer than most polls.

His win was driven by big margins in suburban Northern Virginia, which has trended Democratic over the last decade, and a considerable gender gap. Female voters broke for McAuliffe over Cuccinelli by 50 percent to 42 percent, while Cuccinelli won male voters by four percentage points, according to exit polls.

The governor-elect had some big-name support for his campaign. President Clinton spent days stumping for him, and former Secretary of State Hillary Clinton made her first campaign appearance since leaving the Obama administration alongside McAuliffe, who chaired her 2008 presidential campaign. Both Clintons hosted multiple fundraisers for their longtime friend.

President Obama and Vice President Biden also stumped for him in the campaign’s closing days.

Cuccinelli was outraised by a 2-to-1 margin, and despite some attempts to push a positive message focused on jobs, was effectively tarred as an unyielding conservative out of step with Virginia voters — especially on social issues. An unusually high 20 percent of voters identified abortion as their top issue, according to exit polls, and McAuliffe won two-thirds of their votes.

Recent polling showed that half of those likely to vote for McAuliffe, who was long viewed as a lackluster candidate, were voting more against Cuccinelli than for their own choice.

— This story was last updated at 10:20 p.m.