RICHMOND, Va. — Ralph Northam may have a politician’s dream background, but he’s still struggling how to define himself in the age of Trump.

The Democratic nominee in Virginia’s closely watched race for governor, Northam is banking heavily on his career as a pediatric neurologist and Army doctor who volunteered for two decades as the medical director of a children’s hospice. It’s a strategy that may work, as most polls show Northam with a small but consistent lead over Republican Ed Gillespie.

“He’s just a really good man, in my opinion,” said Elise Emanuel, a retired school guidance counselor from Williamsburg who plans to vote for Northam.

But Northam has been less sure-footed when it comes to how he’ll handle President Donald Trump, frustrating some Democratic supporters and providing an opening for Republican attacks.

“If Donald Trump is helping Virginia, I’ll work with him,” Northam says in one of his TV ads, a marked departure from earlier this year when called Trump “dangerous” and a “narcissistic maniac.”

Northam has also shifted on the removal of Confederate statues, a thorny social issue that Trump helped elevate with controversial remarks following a deadly white nationalist rally in Charlottesville. Immediately after the rally, Northam said he’d be a vocal advocate for removing Confederate statues. He has pulled back in recent weeks, though, emphasizing his position that the issue is best handled at a local level.

Republicans say Northam’s shift of emphasis show he’s a typical politician, sterling background notwithstanding.

“He will say and do anything to win an election,” the Republican Governor’s Association said in a typical email blast.

Northam says he’s “never been one to put my finger up and see which way the wind is blowing politically,” but problems with the Trump question highlight the large role the president has had on the campaign. Gillespie has had Trump problems of his own, keeping the president at an arm’s distance to the dismay of some in his party.

Virginia is the only competitive gubernatorial contest in the country this year and could provide a key indicator of the president’s popularity heading into the 2018 elections.

In Northam, Democrats are hoping a friendly, low-key doctor with a strong southern drawl is the right man for the times.

A standout baseball player from Virginia’s Eastern Shore and a star student at Virginia Military Institute in Lexington, Northam served as an Army doctor treating the first Gulf War’s wounded before running a successful medical practice in Norfolk. When he first ran for office a decade ago, then-Gov. Tim Kaine joked that a “supercomputer” couldn’t have come up with a better resume.

Friends and colleagues say Northam has always been motivated by a genuine desire to help people, not to advance a political career.

Debbie Stitzer-Brame, the executive director of Edmarc Hospice where Northam volunteered as a medical director, said Northam fielded calls at all hours, often providing a “quiet presence” for parents as their child died.

“Whenever he was needed, he was always there,” she said. “This took priority for him.”

Northam’s political rise has been swift. He easily won the lieutenant governor contest four years ago and cruised past an energetic primary opponent earlier this year in what was expected to be a much closer race.

Dr. Svinder Toor, Northam’s medical partner, said Northam showed little interest in a political career when Toor first broached the issue with him. But Northam’s continued frustrations with the health care system, Toor said, prompted him to run.

Northam has made health care reform a centerpiece of his political career and current campaign, winning key allies along the way. He was a leading opponent of a Republican effort to mandate ultrasounds before abortions in 2012, winning him strong support from well-funded abortion-rights groups. He’s also made expanding Medicaid, securing better access to health care for veterans and curbing the state’s opioid epidemic key pieces of his platform.

“It’s like no flash, right? He’s just 100 percent solid,” Cecile Richards, president of Planned Parenthood, which has announced plans to spend $3 million to help Northam’s campaign.

Friends said Northam has relied heavily on his days at VMI to help him manage the grueling and sometimes tedious nature of campaigning. First-year students, known as “rats,” live in Spartan barracks under a harsh system of strict discipline designed to test their physical, mental and emotional limits.

Howard Conduff Jr., Northam’s college roommate for all four years at VMI, said the school left a lasting imprint on Northam on how to overcome hardship and treat others well.

“I think politics needs a Ralph Northam, just the type of individual he is,” said Conduff. “He’s not going to get on a Twitter account and attack people, I promise you that.”