(Jenny Starrs/The Washington Post)

President Trump’s decision to ban transgender individuals from serving in the military highlights recent votes on a related issue by two Republican members of Congress from Virginia whose districts are being targeted by Democrats in 2018.

They took opposite stances on a measure that would have blocked an Obama-era practice requiring the Pentagon to pay for gender transition surgeries and hormone therapy.

The “Hartzler amendment” — named after Rep. Vicky Hartzler (R-Mo.), who proposed adding it to the annual defense policy bill — failed by a vote of 214 to 209.

Rep. Barbara Comstock (R) of Northern Virginia was among the 24 Republicans who joined all Democrats in voting against the amendment.

“Congresswoman Comstock’s vote on this issue reflected her view that [Defense] Secretary [Jim] Mattis, and the professionals at the Defense Department are best equipped to define these policies,” her spokesman, Jeff Marschner, said in a statement. “The congresswoman trusts that Secretary Mattis will provide the clarity and details on what is in the best interest of military readiness going forward.”

Rep. Barbara Comstock (R-Va.). (Jeff Taylor/Associated Press)

Rep. Scott W. Taylor (R), a freshman from Virginia Beach, voted for the amendment, despite a record of supporting LGBT causes through legislation.

Taylor said that Trump’s ban, announced Wednesday via Twitter, is premature because the Defense Department is in the midst of a review of its policies addressing transgender members of the military. “There are heroic military members willing to put their lives on the line and give the ultimate sacrifice on our behalf, regardless of their gender identity,” he said in a statement.

He said he voted for the Hartzler amendment “on the basis of individual medical readiness,” meaning that he did not want taxpayers to cover the year-long post-surgery recuperation period.

Nationally, Democrats hoping to capi­tal­ize on Trump’s low approval ratings in Virginia’s urban regions consider Comstock’s and Taylor’s districts possible pickup opportunities. Multiple Democrats are vying for the nominations to challenge them both.

They say Comstock, whose district voted for Hillary Clinton over Trump by 10 points, is out of step with moderate voters in Loudoun County, in the heart of the district. She has at times criticized Trump and voted against the House Republican health-care bill.

Trump won by three points in Taylor’s district, which has for brief periods been represented by a Democrat.

Trump said in tweets that the government “will not accept or allow transgender individuals to serve in any capacity in the U.S. Military.”

He added: “Our military must be focused on decisive and overwhelming victory and cannot be burdened with the tremendous medical costs and disruption that transgender in the military would entail. Thank you.”

Rep. Scott Taylor (R-Va.). (Steve Helber/Associated Press)

Taylor, a former Navy SEAL and defense hawk who supports Trump, has backed LGBT rights. In the state General Assembly, he sponsored a bill that would have banned LGBT discrimination in housing. Within two months of joining Congress, he introduced similar federal legislation.

Last month he won praise from the Human Rights Campaign as one of two House Republicans — among 238 — to support a federal ban on LGBT discrimination.

Vivian Wise, a transgender woman and Navy officer who works in off-ship communications and lives in Virginia Beach, said the ban leaves her wondering whether she should search for a new job and place to live.

She said she considers Taylor’s vote for the Hartzler amendment an example of “naked bigotry and a backlash against progress the transgender community has made in recent decades.”

“Frankly I wasn’t surprised at all,” she said. “Representative Taylor is something of a water carrier for his party. He seems to be someone who will go along with the majority.

James Parrish, executive director of Equality Virginia, said the fact that Republican support helped kill the Hartzler amendment proves advocacy efforts on behalf of the transgender community are working.

“These are patriotic Americans who are putting their lives on the line to protect our country and preserve our freedoms and there should be no question about whether they should have the same benefits that all active duty members of the military and veterans have,” he said.

Democrats in Congress and across Virginia criticized the ban. Gubernatorial candidate Ralph Northam, a former Army combat medic and graduate of the Virginia Military Institute, tweeted:

“Anyone who wants to serve our country in the military should be welcomed. They’re patriots and should be treated as such.”

Danica Roem (D), a transgender woman who is challenging incumbent Del. Robert G. Marshall (R) for a statehouse seat representing Prince William County, posted a series of tweets, including: “Transgender military members like Logan Ireland & Laila Villanueva have done more to serve & protect America than Donald Trump ever will.”

A spokesman for Ed Gillespie, the Republican gubernatorial nominee, said Gillespie does not support barring transgender people from the military but would be open to changing his views if a Pentagon review of the current policy concludes otherwise.

Gillespie also opposes taxpayer funding for gender transition surgeries for service members, the spokesman said.

Fenit Nirappil contributed to this report.