The US House of Representatives on Thursday narrowly rejected an attempt to undermine rules allowing transgender people to serve in the US military. The measure, defeated in a 214 to 209 vote, would have denied transgender service members certain medical care required for gender transition, such as prescription drugs and surgeries.

The vote on the amendment, which appeared to have significant Republican support, came after a heated afternoon debate.

Republicans have argued the cost of gender-transition treatment is exorbitantly expensive, though the stance encompasses a larger effort by conservatives to resist transgender military integration by claiming it undermines troop readiness.

Rep. Duncan Hunter, a California Republican, said before the vote that military applicants need to "figure out if you're man or woman before you join." The congressman added that if people join the military and then transition to another gender while enlisted, "it will cost the government money, and taxpayers in the country are not going to foot the bill for it."

"Let's make America great again," he concluded.

Top Democrats and LGBT leaders say claims of financial frugality are a ruse designed to mask the right’s larger cultural effort to impede transgender people from serving and marginalize LGBT people in society.

House Democratic Whip Steny Hoyer of Maryland challenged the idea that the push was about spending or military readiness. "This amendment is not about defense,” he said. “It has one purpose and one purpose only: to politically denigrate some of our fellow citizens.”

The debate centered around an amendment titled “Prohibition of Department of Defense Medical Treatment Related to Gender Transition” to a military funding bill, the National Defense Authorization Act.

Republican Rep. Vicky Hartzler of Missouri had previously attempted to amend the spending bill with a measure to fully repeal a policy enacted last year, under the Obama administration, that allows transgender people to serve openly and receive transition related care. Those rules also set a plan in motion to enlist new transgender troops.

Hartzler's first amendment would have terminated the policy entirely and, even more, required out trans service members to be discharged. But she withdrew that amendment after a heated meeting before the House Armed Services Committee on June 28.

The congresswoman came back with new amendment that passed in the House Rules Committee on Wednesday night, which says “funds available to the Department of Defense may not be used to provide medical treatment (other than mental health treatment) related to gender transition to a person entitled to medical care” under the transgender service rules.

The Rules Committee approved her amendment 10-2 along party lines, with Democratic Reps. Jared Polis of Colorado and Patrick McGovern of Massachusetts dissenting.

Twenty-four Republicans ultimately voted against the measure on the floor Thursday, and no Democrats voted in favor of it.

Democrats were ready to fight the measure on the House floor. Minority Leader Nancy Pelosi of California called on the GOP to withdraw the amendment, which she said was “designed to attack the health and dignity of men and women who serve our country."

The ACLU sent a letter to Congress calling the amendment a "discriminatory, unconstitutional attack." LGBT military groups OutServe-SLDN and the American Military Partner Association called it a “vicious attack” designed to block transgender people from enlisting for service at all by denying them basic health care.

In June, the Defense Department said it would delay a policy to allow transgender people to newly enlist in the military. That plan may now be pushed back until 2018.

Hartzler has claimed allowing transgender people into the military saddles taxpayers with medical costs of up to $3.5 billion. She said that stems from $130,000 per transition surgery, plus the cost of hormone treatments, and that providing those treatment could lead troops to take time off and compromise the military's readiness.

Rep. Scott Perry, a Pennsylvania Republican, said that with the country trillions of dollar in debt, refusing to provide services to transgender people is "really just a priority issue."

But former Defense Sec. Ash Carter said last year, when he announced the policy to allow transgender service, that a study by the RAND Corporation found health care "costs would be minimal" and that "the medical treatment that service members who are currently transgender require is fairly straightforward, well understood.”

Rep. Adam Smith of Washington state, the top Democrat on the House Armed Services Committee, said before the vote Thursday there is no study showing a $3.5 billion cost.

Hartzler reached for props in her closing comments ahead of the vote. "This is about addressing Korea," she said, holding up a photo of North Korea’s Supreme Leader Kim Jong-un. "This is about addressing Russia," she went on, as she flashed a photo of Russia’s President Vladimir Putin. And finally, she said, "This is about addressing ISIS," while displaying a picture of masked people in the desert.

"We need every defense dollar to defend against those threats, and not anything else."

This is a developing story. Check back for updates and follow BuzzFeed News on Twitter.