RICHMOND, Va. (AP) — The Latest on Virginia primary races for governor (all times local):

10:20 p.m.

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.

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

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.

___

8:05 p.m.

Ralph Northam has won the Democratic nomination in Virginia’s closely watched race for governor, defeating an insurgent challenger backed by U.S. Sens. Bernie Sanders and Elizabeth Warren.

Northam beat former congressman Tom Perriello, with most polls reporting Tuesday.

The lieutenant governor secured victory thanks in part to his longer time on the campaign trail and fundraising advantage. Northam had the support of the state Democratic Party’s core constituencies, including teachers groups and African-American political and religious leaders. Northam had particularly strong support from some abortion rights and gun control groups, advocates from two areas where Perriello had baggage from past votes in Congress.

On the Republican side, the race remains too close to call between Ed Gillespie and Corey Stewart.

Virginia is one of only two states electing new governors this year, and the contest could serve as a preview to 2018’s midterm elections.

___

3:40 a.m.

Two Virginia Democrats vying to be the face of the resistance to President Donald Trump are squaring off in a gubernatorial primary.

Former U.S. Rep. Tom Perriello is running as a liberal crusader who has the support of national Democrats such as Sens. Bernie Sanders and Elizabeth Warren. He has promised to stand up to both Trump and the entrenched business interests that dominate state politics.

Lt. Gov. Ralph Northam also vowed to fight Trump but said he’ll work with state Republicans to move a progressive — and realistic — agenda forward.

On the Republican side, front-runner Ed Gillespie, a moderate Washington insider, is trying to fend off under-funded but spirited campaigns from avid Trump supporter Corey Stewart and state Sen. Frank Wagner.

Polls open at 6 a.m.