By Alan Suderman Associated Press

RICHMOND, Va. – For the two mild-manned moderates vying to be the next governor of Virginia, running for office in the Trump era makes for some awkward looks.

Republican Ed Gillespie, a polished Washington insider who has long advocated that the GOP needs to be more welcoming of minorities and immigrants, is now campaigning on promises to crack down on illegal immigration and prevent Confederate statues from being taken down. Ralph Northam, the Democratic lieutenant governor who boasts of his good working relationships with Republicans, has pledged unyielding resistance to President Donald Trump and called him a “narcissistic maniac” and a “dangerous” man.

The closely watched race for Virginia governor is ramping up for the post Labor Day push – when voters typically start to pay more attention – with the two major party candidates still trying to feel their way with Trump in the White House. Both are trying to stick with the traditional basics of a gubernatorial campaign – talking about jobs, schools, health care – while also keeping Trump’s opponents and supporters fired up.

“In a post-Trumpian election cycle, neither campaign can really cut loose from their base,” says Shaun Kenney, a former executive director of the Republican Party of Virginia.

A swing state that resembles America in miniature, the outcome in Virginia could serve as an early referendum on Trump’s first year in office and a bellwether for the 2018 midterm elections for control of Congress and statehouses around the country.

Only two states are electing new governors this year, and Virginia’s race is expected to be much more competitive than New Jersey’s. The Virginia race is getting plenty of out-of-state attention, and billionaire-backed outside groups like the conservative Americans for Prosperity and the liberal NextGen America – supported by industrialists Charles and David Koch and environmentalist Tom Steyer, respectively – have pledged significant spending.

Public opinion polls have showed a competitive contest between Gillespie and Northam.

The growing Washington suburbs in the northern part of the state, which are more diverse and liberal than other parts of Virginia, have helped Democrats hold an edge in recent statewide elections. Virginia was the only southern state Hillary Clinton won last year and Democrats have won every statewide election since 2012.

Gillespie is no stranger to the state’s changing demographics and the obstacles Republicans must overcome to win statewide. His underdog bid to unseat U.S. Sen. Mark Warner in 2014 fell just short because of the Democratic wall in Northern Virginia.

Now Gillespie is trying to win over those same suburban voters while also appealing to the state’s Trump supporters, many of whom live in economically depressed rural areas and are skeptical of the former Washington lobbyist and confidante to President George W. Bush.

The result is that Gillespie has largely tried to avoid talking about Trump while mimicking some of the president’s positions. Gillespie’s campaign messaging alternates between a center-right focus on lower taxes to Trump-like stances of cracking down illegal immigration and expressing support for preserving Confederate monuments.

“Gillespie is essentially caught,” said Quentin Kidd, a political science professor at Christopher Newport University. “He’s being pulled in two directions.”

Northam has also struggled to reconcile the disparate parts of his party, with two proposed natural gas pipelines serving as flashpoints. Anti-pipeline protestors, which include land owners and environmentalists, have castigated Northam for not directly opposing the pipelines. Northam has not said outright if he supports or opposes the pipelines, only that they should meet strict environmental safeguards if built.

Northam also has tried to appeal to the strong anti-Trump feelings of his base with sharp attacks on the president, calling Trump a liar and a danger to the country.

The violent white nationalist rally in Charlottesville last month over the city’s planned removal of a state of Confederate Gen. Robert E. Lee highlighted how polarized the race has become.

The Republican Party of Virginia had to apologize after it put out a tweet accusing Northam of having “turned his back on his own family’s heritage” by supporting the removal of Confederate monuments because one of his ancestors may have fought for the Confederacy. Democrats, meanwhile, have repeatedly criticized Gillespie for not explicitly condemning Trump’s racially fraught comments about Charlottesville, with one group of Jewish lawmakers saying it was a “moral abdication.”