RICHMOND, Va. (Reuters) - Speaking as a folksy physician running for Virginia governor, Democrat Ralph Northam vowed in a recent campaign ad to fight Donald Trump on cuts to education funding, environmental protections and health care access.

FILE PHOTO: Virginia Lieutenant Governor Ralph Northam, Democratic candidate for governor, delivers remarks before introducing former U.S. President Barack Obama to speak at a rally with supporters in Richmond, Virginia, U.S. on October 19, 2017. REUTERS/Jonathan Ernst/File Photo

But Northam said he will work with the Republican president when it is in the state’s interest.

The balancing act puts Northam, a moderate lieutenant governor with a low-key campaign style, on the front lines of his party’s search for a strategy to exploit Trump’s unpopularity in politically divided states such as Virginia.

He is running against Ed Gillespie, former chairman of the Republican National Committee.

The Nov. 7 general election in the competitive southern state is seen as a bellwether for next year’s midterm elections, when voters will decide whether Republicans should continue to control the U.S. Congress and a majority of state governments.

After denouncing Trump as a “narcissistic maniac” during the primary campaign, Northam has since dialed back the vitriol. His emphasis on workforce education and policy matters heeds criticism that Democrats lost the White House because voters did not hear what the party stood for.

“The Northam strategy is talk Trump, but don’t just talk Trump,” said Stephen Farnsworth, a professor of political science at the University of Mary Washington, noting that Northam seeks to broaden his appeal to uncommitted voters.

Most polls show Northam narrowly ahead in a contest Democrats consider a must-win. Virginia is one of only 15 governors’ mansions still held by the party, and its current governor cannot run for re-election due to term limits.

Former Democratic President Barack Obama returned to the campaign trail this week for the first time since leaving office to stump for candidates in Virginia and New Jersey, the two states with gubernatorial elections this year. Without naming Trump, he called on voters to send a message by backing candidates like Northam.

A recent poll showed nearly one in three likely Virginia voters were factoring Trump into their decision in the governor’s race, according to a survey from the Wason Center for Public Policy at Christopher Newport University. Northam’s supporters overwhelmingly disapproved of Trump.

Distain for the Republican president is why Niel Manson, a 72-year-old retired engineer living near the capital city of Richmond, became a Democrat nine months ago.

Yet the former independent called Northam wise to make his campaign about more than merely reacting to Trump.

“There is no benefit in getting in a discussion with Trump, because he changes his mind every 24 hours,” Manson said.

The Northam campaign said it has intentionally focused on policies when talking about Trump, seeking to draw parallels to Gillespie.

Northam starts another recent ad highlighting differences between the gubernatorial candidates on climate change.

“Now Ed’s going right along with Donald Trump as he tries to roll back our clean air and water protections,” the Democrat says from a picnic table at a waterfront park.

The strategy works to connect the president to a Republican candidate who is not always in lock step with him, said Jennifer Duffy, who analyzes gubernatorial races for the non-partisan Cook Political Report.

She said campaigns gearing up for next year’s midterms will learn from Virginia whether such messaging sways independents, or motivates Democrats to turn out in greater numbers than typical for non-presidential years.

“This is our first real election to see how these arguments about Trump really do impact Republican candidates,” Duffy said.

Gillespie’s campaign declined to comment about Trump’s impact on the race. The president endorsed Gillespie but has not campaigned with him.

Vice President Mike Pence headlined a recent rally for the candidate in southwest Virginia’s heavily Republican coal country.

Democratic voter Erin Siraguse, 34, said she based her support for Northam on issues such as his efforts to address affordable housing for teachers around her home in Fairfax County in northern Virginia.

She admires how Northam has handled the president’s shadow over this year’s most competitive state race.

“Lieutenant Governor Northam has done a wonderful job of talking about Trump without mentioning Trump,” she said.