Rep. Barbara Comstock, R-Va. (Alex Brandon/Associated Press)

Rep. Barbara Comstock, reelected on Nov. 8 in the battleground communities of the District’s western Virginia suburbs, really knows the 10th Congressional District.

With roughly 70 percent of the district’s voters residing in Fairfax and Loudoun counties, the first-term incumbent had to walk a careful line during this year of Donald Trump. For most of the campaign, Comstock neither broke with the Republican nominee nor sang his praises, hoping to avoid losing the support of both potential swing voters and Trump loyalists.

Without considerable approval among those in each group, Comstock might not have won the district, which four years ago had split 50 percent for Republican presidential nominee Mitt Romney and 49 percent for President Obama. With its decidedly purple hue, both Democrats and Republicans recognized Virginia’s 10th as an unusually vulnerable seat in the nation’s highly gerrymandered Congress, where nearly every district was drawn to be either safely Democratic or safely Republican.

As a result, more than $11.6 million in campaign cash poured into the 10th District, leading to nasty advertising wars and very aggressive voter outreach efforts from McLean to the West Virginia border.

But when a recording emerged of Trump bragging about groping women, the Republican nominee went from being a drag to being an anchor, threatening to sink Comstock’s reelection. Wisely, she cut Trump loose, saying that she could not support him and saying that she preferred Indiana Gov. Mike Pence, the Republican vice-presidential nominee, to Trump.

As a result, there was more than a little tension between Trump Republicans and Comstock Republicans working within the district at political events during the campaign’s final weeks.

In the end, Comstock demonstrated that she was far more popular in the district than Trump was. Virginia’s 10th Congressional District has 200 precincts, and Comstock received more votes than Trump in every single one of them.

More often than not, Comstock’s advantage over Trump was substantial. Trump came within five percentage points of Comstock in only eight of those 200 precincts, and all of those eight lie in the deep-red areas of rural Frederick and Clarke counties. In 110 of those 200 precincts, Comstock ran ahead of Trump by 10 percentage points or more.

Nowhere was this disparity more evident than in wealthy inside-the-Beltway precincts included in the 10th District. In Chain Bridge and Langley, for example, Comstock earned the support of 53 percent and 56 percent of the votes, respectively. Democratic presidential nominee Hillary Clinton won these same Fairfax County precincts by 16-point margins.

The Rolling Ridge precinct of Loudoun County, on the other hand, was LuAnn Bennett territory. The Democratic challenger received more than 64 percent of the vote there, making it one of her best precincts. Comstock’s total there was slightly less than 35 percent, but that was far better than Trump’s 27 percent share of the vote in Rolling Ridge.

Trump — who lost the 10th District overall — did very well in the Russell precinct in Clarke County, where he received two-thirds of the vote. But here, too, Comstock did better: She received 72 percent of the vote in the precinct, the largest one in Clarke County, just west of Loudoun.

While Trump’s economic-reform message resonated with many Virginians, the theme was most effective in more financially troubled parts of the state, like Southside and southwest Virginia. Simply put, a Republican presidential candidate saying that the jobs of many federal workers and government contractors might be in jeopardy is not an asset for a Republican congressional incumbent facing a strong challenger in Northern Virginia.

As the electoral college demonstrates, Trump’s message hit in enough places in the nation overall to make him the winner. But the controversial candidate was a much tougher sell in Virginia’s 10th District.

Comstock acted accordingly and won a second term.

Stephen J. Farnsworth is a professor of political science at the University of Mary Washington, where he directs the Center for Leadership and Media Studies. Stephen Hanna is a professor of geography at the University of Mary Washington.