President Trump announced on Twitter on Wednesday that he will ban transgender people from serving in the military in any capacity, an abrupt reversal of an Obama administration decision to allow them to serve openly and a potential end to the careers of thousands of active-duty troops.

The decision halts a years-long process of advancing rights for lesbian, gay, bisexual and transgender people in the U.S. military that began with the repeal of the “don’t ask, don’t tell” policy in 2010. And the nature of the announcement left Republicans and Democrats in Congress concerned about the seeming broad scope of Trump’s order.

Citing the need to focus on what he called “decisive and overwhelming victory,” Trump said that the military cannot accept the burden of higher medical costs and the “disruption” that transgender troops “would entail.”

“After consultation with my Generals and military experts, please be advised that the United States Government will not accept or allow transgender individuals to serve in any capacity in the U.S. Military,” Trump wrote on Twitter. “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.”

Sen. John McCain (R-Ariz.), the chairman of the Senate Armed Services Committee who in 2010 opposed ending “don’t ask, don’t tell,” criticized Trump’s decision in a statement, attacking both how it was delivered and its implications for active-duty transgender troops.

(Whitney Shefte/The Washington Post)

“The president’s tweet this morning regarding transgender Americans in the military is yet another example of why major policy announcements should not be made via Twitter,” McCain said. “The statement was unclear. The Department of Defense has already decided to allow currently serving transgender individuals to stay in the military, and many are serving honorably today. Any American who meets current medical and readiness standards should be allowed to continue serving. There is no reason to force service members who are able to fight, train and deploy to leave the military — regardless of their gender identity,” McCain said.

Trump was lobbied for over a year by conservative Republicans to roll back the Obama administration policy change. Christian conservative leaders pressed him on the issue as a candidate in June 2016 during a meeting in New York just after Trump secured the Republican nomination for president. Many of them said the military is no place for “social experimentation” at the expense of military readiness.

Although they were pleased with Trump’s decision, Wednesday’s announcement came with no warning to those same conservative leaders. It also was a surprise to many on Capitol Hill.

Trump’s decision comes two weeks after the House rejected an amendment to the annual defense policy bill that would have blocked the Pentagon from offering gender transition therapies to active-duty service members. Twenty-four Republicans joined 190 Democrats voting to reject the measure.

But conservative lawmakers — many of them members of the House Freedom Caucus — had threatened to withhold support for a spending bill if Congress did not act to prohibit the Pentagon from paying for the procedures. The impasse broadly threatened government spending, but most importantly for Trump, it potentially held up money that had been appropriated for the border wall between the United States and Mexico, a key promise he had made during the campaign.

[Hill Democrats slam Trump’s military transgender ban, while GOP is caught by surprise]

A White House official and a House GOP official confirmed that Reps. Mark Meadows (R-N.C.), Jim Jordan (R-Ohio) and Scott Perry (R-Pa.), all Freedom Caucus members, were in talks with the White House and House leadership on the issue.

(Whitney Leaming/The Washington Post)

They were willing to accept a Defense Department or White House provision that addressed paying for procedures — well short of a ban on transgender people serving in the military, according to the House official who, like others, spoke on the condition of anonymity because he was not authorized to speak publicly on the issue.

Trump went well beyond what they had requested.

Earlier this year, Trump’s military leadership had signaled that they needed more time to fully assess the implementation of the last significant piece of the Obama administration’s approach, delaying the entry of transgender military recruits until the end of 2017. The policy in place would have allowed them to begin serving July 1, but Defense Secretary Jim Mattis delayed it just before the deadline, citing a need for more study.

The six-month delay was requested by the Joint Chiefs of Staff and would have allowed a further review of how integrating transgender recruits would affect the military’s “readiness and lethality,” Mattis said in a memo last month. That review was due in early December.

Mattis noted that the delay “in no way presupposes the outcome.”

[On eve of deadline, Pentagon delays plan to allow transgender recruits by 6 months]

White House spokeswoman Sarah Huckabee Sanders defended Trump’s decision, saying it was purely focused on military readiness. Yet when pressed by reporters on how the new policy would be implemented and how it would affect currently serving transgender troops, Sanders deferred the questions to the Pentagon. She said Trump had made the decision and informed Mattis of the policy change Tuesday.

“Look, I think sometimes you have to make decisions, and once he made a decision, he didn’t feel it was necessary to hold that decision, and they’re going to work together with the Department of Defense to lawfully implement it,” Sanders said.

Aside from a short statement, the Pentagon referred all questions regarding Trump’s tweets to the White House.

[Trump’s ‘LGBT rights’ promises were tied to war on ‘radical Islam’]

In a sign of how quickly political and social norms have shifted in Washington, many Republican lawmakers spoke out against Trump’s announcement.

As well as McCain, Republican Sens. Orrin G. Hatch (Utah); Joni Ernst (Iowa), an Army veteran; and Richard C. Shelby (Ala.) issued statements calling the president’s decision into question.

Under former defense secretary Ashton B. Carter, the military lifted the ban on transgender troops and was given one year to determine how to implement a policy that would allow transgender service members to receive medical care and ban the services from involuntarily separating people in the military who came out as transgender.

Thousands of troops serving in the military are transgender, and some estimates place the number as high as 11,000 in the reserves and active-duty military, according to a Rand Corp. study commissioned by the Defense Department.

The Rand study estimated that gender-transition-related medical treatments would cost the military between $2.4 million and $8.4 million annually.

Brad Carson, a former congressman who worked on transgender policy deliberations under the Obama administration, said in an interview Wednesday that months of delays last year in implementing a change in transgender policy “left the door open” to Trump’s action and potentially invites litigation challenging the president’s decision.

“That being said, just from the tweets, it seems as if what he is doing is rolling back already implemented policies, which will force out several hundred openly transgender service members out of the military,” Carson said.

Also Wednesday, the Justice Department filed a legal brief in a case before the U.S. Court of Appeals for the 2nd Circuit arguing that LGBT people are not protected from discrimination under Title VII of the Civil Rights Act.

As a political candidate, Trump largely avoided issues related to LGBT rights, even while many in his family — including daughter Ivanka Trump — have been vocal supporters of LBGT people.

But since taking office, the Trump administration has rolled back protections, including those for transgender children in public schools. And earlier this year, even before the decision on public schools, the Pentagon quietly rescinded a directive to Defense Department schools that students were free to use the bathrooms and locker rooms consistent with their gender identity.

[The Pentagon’s history of resisting transgender troops]

The White House also did not recognize LGBT Pride Month in June, although other members of his administration did so, including Secretary of State Rex Tillerson.

When asked whether Ivanka Trump and Jared Kushner, the president’s senior adviser and son-in-law, were involved in the discussions before Trump’s tweets Wednesday, the White House official said, “It actually may have caught them unaware.”

Aaron Belkin, director of the Palm Center, a think tank that has helped the Pentagon research transgender people serving in the military, released a statement condemning the move.

“This is a shocking and ignorant attack on our military and on transgender troops who have been serving honorably and effectively for the past year,” Belkin said.

Philip Rucker, Dan Lamothe, Jenna Johnson, Ed O’Keefe, Robert Barnes and Christopher Ingraham contributed to this report.