JUST WATCHED

Gillespie wins GOP Virginia primary

MUST WATCH

Story highlights

On the Democratic side, Lt. Gov. Ralph Northam is on track to win the nomination

The close Republican race came as a major surprise

Washington (CNN)Ed Gillespie was expected to hold onto a narrow lead to win the Republican nomination for Virginia governor in his party's primary election Tuesday evening, CNN projected.

On the Democratic side, Lt. Gov. Ralph Northam is on track to win the nomination for Virginia governor, CNN has projected.

Gillespie's tight victory over Prince William County Board of Supervisors chair Corey Stewart came as a major surprise. Observers initially expected it to be an easy win for Gillespie, a former chairman of the Republican National Committee. Frank Wagner, a senator in the commonwealth's legislature, trailed in third place.

Meanwhile, Northam's win capped off fierce competition on the Democratic side, where he faced off against former congressman Tom Perriello. And turnout in the Democratic primary far outpaced the Republican side.

In a statement congratulating Northam, outgoing Democratic Gov. Terry McAuliffe linked the Republican field to President Donald Trump.

Read More

Tuesday's elections marked the first time both parties held contests on the same day in the commonwealth's history.

A fierce fight

Stewart's surprise performance came after a campaign during which he engendered significant controversy.

Last October, he appeared on a show hosted by Mike Cernovich, a member of the pro-Trump, far-right media who has dismissed the existence of date rape. Two months ago, Stewart participated in an "ask me anything" session on Reddit's largest pro-Trump forum, where, among other things, he called Gillespie a "cuckservative." He had previously served as the Trump campaign chair for Virginia before being fired from the unpaid position.

Gillespie, a former George W. Bush aide, campaigned off the goodwill he established with Republicans after his narrow loss to Democratic Sen. Mark Warner in 2014. Gillespie worked to tiptoe around the presence of Trump, embracing policies that are popular with Republicans without directly tying his campaign to the President.

JUST WATCHED

Critical Counties - Prince William, VA: The new America

MUST WATCH

Gillespie basically ignored his competition, including the flame-throwing Stewart, and the strategy seemed to work. Most polls showed Gillespie with a double-digit lead before Election Day.

A third candidate, Wagner, struggled to gain traction, despite winning the endorsement of The Washington Post's editorial board.

For Democrats, the race had been framed as a reboot of the Bernie Sanders-Hillary Clinton contest.

Some viewed the close battle as a pitting of the Sanders wing of the party, as channeled by Perriello, against the Clinton wing of the party, represented by Northam.

But the comparison was never a perfect fit. Northam had pushed his campaign further to the left and has described Trump as a narcissistic maniac -- while Perriello instead attempted to reach out to Trump voters by selling a message of economic populism framed through a progressive perspective.

Both the Democratic and Republican contests featured established candidates with lengthy political careers facing off against insurgent, populist candidates hoping to upset the power bases of their respective parties.