Republican Ed Gillespie has narrowly won his party's nomination in Virginia's race for governor, eking out a victory against an ardent supporter of President Donald Trump.

Gillespie is a former Republican National Committee Chairman who had a huge fundraising advantage and enjoyed the solid backing of most state elected Republicans, but largely kept Trump at arm's length during the campaign.

VIRGINIA PRIMARY | Latest election results

On Tuesday, he barely defeated Corey Stewart, a former Trump state campaign chairman who made preserving Virginia's Confederate history a top campaign issue.

RELATED: Northam wins Democratic nomination for Va. governor

The close results shocked many political watchers and shows Trump's enduring appeal among Republican voters in Virginia.Gillespie will face Democrat Lt. Gov. Ralph Northam in the general election.