President Trump abruptly announced a ban on transgender people serving in the military on Wednesday, blindsiding his defense secretary and Republican congressional leaders with a snap decision that reversed a year-old policy reviled by social conservatives.
Mr. Trump made the declaration on Twitter, saying that American forces could not afford the “tremendous medical costs and disruption” of transgender service members. He said he had consulted generals and military experts, but Jim Mattis, the defense secretary, was given only a day’s notice about the decision.
Mr. Trump elected to announce the ban in order to resolve a quietly brewing fight on Capitol Hill over whether taxpayer money should pay for gender transition and hormone therapy for transgender service members. The dispute had threatened to kill a $790 billion defense and security spending package scheduled for a vote this week.
But rather than addressing that narrow issue, Mr. Trump opted to upend the entire policy on transgender service members.
His decision was announced with such haste that the White House could not answer basic inquiries about how it would be carried out, including what would happen to openly transgender people on active duty. Of eight defense officials interviewed, none could say.
“That’s something that the Department of Defense and the White House will have to work together as implementation takes place and is done so lawfully,” Sarah Huckabee Sanders, the White House press secretary, said.
Still, the announcement pleased elements of Mr. Trump’s base who have been dismayed to see the president break so bitterly in recent days with Attorney General Jeff Sessions, a hard-line conservative.
Civil rights and transgender advocacy groups denounced the policy, with some vowing to challenge it in court. Pentagon officials expressed dismay that the president’s tweets could open them to lawsuits.
The ban would reverse the gradual transformation of the military under President Barack Obama, whose administration announced last year that transgender people could serve openly in the military. Mr. Obama’s defense secretary, Ashton B. Carter, also opened all combat roles to women and appointed the first openly gay Army secretary.
And it represented a stark turnabout for Mr. Trump, who billed himself during the campaign as an ally of gay, lesbian, bisexual and transgender people.
The president, Ms. Sanders said, had concluded that allowing transgender people to serve openly “erodes military readiness and unit cohesion, and made the decision based on that.”
Mr. Mattis, who was on vacation, was silent on the new policy. People close to the defense secretary said he was appalled that Mr. Trump chose to unveil his decision in tweets, in part because of the message they sent to transgender active-duty service members, including those deployed overseas, that they were suddenly no longer welcome.