As voters in her Northern Virginia district overwhelmingly backed Hillary Clinton for president two years ago, Rep. Barbara Comstock (R) withstood that Democratic energy and handily won reelection.

Now in her bid for a third term, Comstock is formidable — she has raised $3.2 million, enjoys wide name recognition and the power of incumbency, and is considered the overwhelming favorite in the GOP primary on Tuesday against Shak Hill, a relative unknown and self-­described inspirational speaker.

Still, she is not taking anything for granted.

Comstock’s campaign has rolled out a series of attacks against Hill, a retired Air Force pilot who unsuccessfully ran for the GOP nomination for Senate in 2014.

It produced a website that invites viewers to “Meet Shady Shak. Creepy candidate. Can’t win,” which criticizes his hiring decisions and accuses him of posting lewd material online.

In radio ads reinforcing the message, a menacing-sounding male voice asks “Do you know the real Shak Hill?”

In response, Hill’s campaign said an automated service inadvertently posted lewd articles on his website.

Hill, 53, says Comstock, 58, isn’t conservative enough for the sprawling 10th District and is attacking what he calls her “liberal voting record.”

He points to her votes against a House bill that would have remade the Affordable Care Act and against a measure that would have blocked an Obama-era practice requiring the Pentagon to pay for gender transition surgeries and hormone therapy.

Hill called Comstock “a disaster in every Republican aspect.” The district “deserves a representative who will not lie about themselves and then switch and vote as a liberal. I will vote like Barbara Comstock campaigned last time she ran — conservative!” said Hill, who declined an interview request but responded to emailed questions.

He also assailed Comstock, referring to her as a “Never Trumper” because she called Trump’s remarks “vile” and “disgusting” in the now-infamous “Access Hollywood” tape, in which he bragged about grabbing women. The tape was made public a month before the presidential election in 2016, prompting Comstock to call on Trump to step aside and allow the Republican Party to select another candidate.

Nevertheless, since Trump took office, Comstock has voted with her party most of the time, supporting Trump and the GOP’s efforts on deregulation, tax cuts, abortion and other issues.

“What we see here is a savvy politician trying to navigate a very difficult political environment,” said Stephen J. Farnsworth, a professor of political science at the University of Mary Washington.

“Comstock is in a difficult spot here because if she offers up too aggressive a defense of President Trump, she’s likely to lose in the general election,” he said. “And since Comstock faces a greater threat in November than in June, it makes sense to focus on the problems of her Republican opponent.”

Her primary strategy shows she’s “threading the needle” by attacking Hill in ways that won’t undermine her chances in November, he said.

Comstock’s campaign defended the approach.

“Like in every other of our winning campaigns, we are sprinting through the finish line,” her campaign manager, Susan Falconer, said in a statement. “Shak Hill is an unvetted, perennial failed candidate who isn’t who he claims to be. It’s long past time to inform people of his past.”

Later, lawyers from her campaign petitioned a radio station to stop airing an ad from Hill that they argue falsely claims Comstock knew the identities of members of Congress who privately settled claims of sexual misconduct, suggesting that she was complicit in keeping their behavior shrouded in secrecy.

During the past year, Comstock has been one of the loudest voices on Capitol Hill calling for reforms to the process for reporting sexual harassment.

Comstock can afford to spend money on the primary. She has raised more than $3.2 million for her campaign, while Hill raised just $245,340.

She sent voters a four-page mailer that touts her ability to get “conservative results for Virginia,” as well as endorsements from John Bolton, Trump’s national security adviser; former House Speaker Newt Gingrich; and the National Rifle Association.

It also says she is “pro-border wall to stop illegal immigration,” “pro-life,” and “pro-2nd Amendment.”

In the final days of the campaign, Vice President Pence recorded a phone message urging voters to cast ballots for his “friend” Comstock, whom he called “a strong, effective, conservative leader,” according to Comstock’s spokesman Jeff Marschner.

Last week, she trumpeted the support of her longtime friend David Bossie, chairman of the conservative advocacy group Citizens United and Trump’s 2016 deputy campaign manager.

Hours later, Hill’s campaign hosted a “pro-Trump Meet and Greet” with a special guest: Fox News contributor and former Trump aide Sebastian Gorka.

The winner of the GOP primary will face the winner of the six-way Democratic contest, which will also be decided Tuesday.

Then the question becomes whether the Republican can overcome Trump’s unpopularity in the district, which includes parts of Fairfax and Prince William counties, all of Loudoun County and a rural swath to the west.

Three independent analysts consider the race a “toss-up.”