(CNN) -- Terry McAuliffe, a former Democratic National Committee chairman, will beat Republican state Attorney General Ken Cuccinelli Tuesday to become Virginia's next governor, CNN projects, ending a race that largely focused on national issues and saw heated attacks between the two candidates.
Of the two gubernatorial races this year, the contest in Virginia was by far the closest.
For months McAuliffe held a small, consistent lead in public opinion polls over Cuccinelli, who was considered a hero by many tea party supporters and other grass-roots activists, thanks to his very public conservative crusades, including his push against Obamacare.
A third-party candidate, libertarian Robert Sarvis, was thought to be a potential spoiler. Sarvis was taking around 8 percent to 10 percent of the vote in recent polls, a significant chunk with the race between the Republican and Democratic candidates so close.
McAuliffe will succeed Republican Gov. Bob McDonnell, who didn't run for re-election because Virginia governors cannot serve consecutive terms.
The main two campaigns engaged in nasty political warfare that took over the airwaves in Virginia. McAuliffe made sure women were aware of Cuccinelli's support of "personhood" legislation that critics say restricts abortion and some forms of birth control.
Cuccinelli has frequently highlighted federal investigations of an electric car company that McAuliffe co-founded.
Both sides also attempted to frame the race as a referendum on larger national issues. Cuccinelli's supporters argued a vote against McAuliffe was a vote against Obamacare.
McAuliffe and Democrats pinned Cuccinelli as a tea party activist, linking him to conservative lawmakers in Washington who initiated a strategy that eventually led to last month's government shutdown.
Although McAuliffe came out on top, neither candidate was particularly well-liked. A Quinnipiac Poll released Monday showed 42 percent of likely voters had a favorable opinion of the Democrat, while 45 percent had an unfavorable view. Cuccinelli also had a negative favorability rating, 38 percent to 52 percent.
Cuccinelli particularly struggled to gain support among women and to unite the commonwealth's GOP base.
High-profile surrogates came out to bat for the two main gubernatorial hopefuls in the last weeks of the campaign. President Barack Obama, former President Bill Clinton, former Secretary of State Hillary Clinton and Vice President Joe Biden all hit the trail for McAuliffe.
Cuccinelli, meanwhile, had support from GOP Gov. Bobby Jindal of Louisiana, Sen. Rand Paul of Kentucky and former GOP presidential candidate Mike Huckabee of Arkansas. Former Rep. Ron Paul also endorsed the attorney general and headlined an event for Cuccinelli on Monday night.
With McAuliffe's win, he breaks a long streak in Virginia gubernatorial contests. In the last nine elections, the party controlling the White House lost the governor's race.
When McAuliffe is sworn in, Republicans will control 29 of the nation's governorships, down from 30 before his victory.
™ & © 2013 Cable News Network, Inc., a Time Warner Company. All rights reserved.