Rep. Barbara Comstock (R-Va.) was the only Republican member of Congress from Virginia or Maryland to vote against the GOP bill to overhaul the health insurance system on Thursday. (Jeff Taylor/AP)

During House Speaker Paul D. Ryan’s push this week to pass legislation that would overhaul the nation’s health-care system, Northern Virginia Rep. Barbara Comstock stood alone as a “no” vote among her Republican Party colleagues in the Washington region.

The reason Comstock gave is that the latest version of the American Health Care Act, which passed by a vote of 217 to 213, does not protect people with preexisting conditions and has too many other “uncertainties” in its aim to offer a better model than Obamacare.

But as the two-term congresswoman and Ryan ally prepares for what is expected to be a competitive election in November 2018, political analysts see her opposition as a pragmatic act of survival in the increasingly moderate 10th Congressional District, where Hillary Clinton won 51 percent of the vote in last fall’s presidential election.

Many of the other 19 Republicans who voted against the health-care bill also are facing potentially tight reelection races, said David Wasserman, who analyzes congressional elections for the Cook Political Report and lists Comstock as one of the three most vulnerable Republicans in the House.

“She’s the only Republican left who represents any area inside the D.C. Beltway,” Wasserman said. “That helps explain why she was one of the few Republicans to get a coveted pass from leadership to vote ‘no’ on health care.”

(Jenny Starrs/The Washington Post)

Comstock’s office said the congresswoman opposed the bill out of concern over some of its provisions, in particular one that would allow states to let insurers again charge more to customers with preexisting medical problems — a practice that the current Affordable Care Act prohibits.

A spokesman declined to make Comstock available for comment but said her position on health care has been consistent.

Comstock — whose district stretches from the southwestern Washington suburbs to the border with West Virginia — campaigned for reelection to a second term on a pledge to revise the current health-care law and has repeatedly voted to begin the process of repealing Obamacare.

“My goals on health care reform are to provide patient-centered reforms that provide better access to high quality, affordable care and covers pre-existing conditions without lifetime limits,” Comstock said in a statement posted on her congressional website after Thursday’s vote. “I did not support the AHCA today because of the many uncertainties in achieving those goals.”

Jim Hoeft, publisher of the Bearing Drift conservative blog in Virginia, said Comstock is walking a fine line in a portion of the state whose changing demographics are making elections more favorable to Democrats.

Comstock easily won her first election in 2014 with 56 percent of the vote but faced a closer election last year, when she won with 53 percent in the district where voters are often concerned about the economic effects of federal spending cuts and traffic-clogged roads.

On health care, Comstock may be responding to changes in the district by reflecting the views of Republican voters who may be happy with some aspects of Obamacare, Hoeft said.

(Daron Taylor/The Washington Post)

“It doesn’t take a rocket scientist to look at that and say, ‘She’s representing her constituency,’ ” he said. “That’s the whole point of being a representative. You’re representing the interests of your district.”

But going down on record as opposed to what has been a central component of President Trump’s agenda could backfire with more conservative voters in what is likely to be a close November election, said Nathan Gonzales, editor and publisher of Inside Elections, which analyzes federal and gubernatorial elections.

“For some Republicans in the district who wanted Republicans to act against Obamacare, she risks them sitting out the midterm elections,” Gonzales said. “She needs every Republican possible in order to win. She doesn’t have a lot of margin for error.”

On Friday, the Republican Party sought to defend Comstock against any backlash.

“No one knows Northern Virginia better than Barbara Comstock,” the National Republican Congressional Committee said in a statement. “She clearly demonstrated her independence and we applaud her for keeping her constituents in the forefront of her mind in all decisions she makes.”

But in Loudoun County, whose voters often determine the outcome of elections in the 10th District, Comstock’s health-care vote generated some confusion and controversy on a Republican voters’ Facebook page.

“I’m very disappointed in Congresswoman Barbara Comstock for this,” one commenter wrote. “I get that it’s political theater. But it’s dishonorable.”

“It’s amazing how some conservatives will do anything they can to find fault with Congresswoman Comstock,” another poster responded. “I’m positive that had she voted for the bill the same people mad at her now would be mad at her for that vote.”

Democrats, meanwhile, plan to characterize Comstock as a cynical politician out to win at all costs — a tactic that other Comstock opponents have tried.

“I don’t think Barbara Comstock is fooling anybody,” said Lindsey Davis Stover, a former Obama administration official who is one of four Democratic candidates so far vying to run against Comstock in November. “What she’s doing is not courage; it’s politics.”

State Sen. Jennifer T. Wexton (D-Loudoun), another candidate, said Comstock’s vote is “less about any core values that she may have than it is about political expediency and survival mode.”

“If she really wanted to be a leader and do the best thing for her constituents, why was she not speaking out publicly against it?” Wexton said.

The other two Democrats in the race — former Fairfax County teachers union president Kimberly Adams and Dan Helmer, an Army veteran and Rhodes scholar — could not be reached for comment. Helmer is on active military duty, a spokesman said.

Dorothy McAuliffe, the wife of Gov. Terry McAuliffe (D), has said she is “seriously considering” running for the seat but has not made a decision.