US President Donald Trump has banned transgender people from serving in the military "in any capacity".
Mr Trump shot off three tweets Wednesday morning, US time, to make the surprise announcement.
"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 US military," he tweeted.
"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."
Mr Trump did not make it clear whether serving transgender people would be expelled from the armed services.
Transgender people were allowed to serve openly in the US military for the first time last year under former president Barack Obama, when then defence secretary Ash Carter lifted a ban.
White House spokeswoman Sarah Huckabee Sanders said the President was concerned about the policy.
"This is a very expensive and disruptive policy and, based on consultation that he's had with his national security team, he came to the conclusion that is erodes military readiness and unit cohesion and made the decision based on that," she told reporters in Washington Wednesday afternoon.
The Pentagon, which is responsible for all US military matters, was reportedly blindsided by Mr Trump's decision.
A study by non-profit research think tank RAND found that there were between 1320 and 6630 active transgender officers in the US military as of last year.
The research is at odds with the President's assertion that having transgender people in the military amounted to "tremendous medical costs and disruption".
The study found that only a fraction of those officers - between 29 and 129 - would seek medical assistance related to gender transition that could "disrupt their ability to deploy".
This number was "negligible" compared to the 102,500 non-deployable soldiers in the army alone in 2015.
And it also concluded that the cost of offering transition-related healthcare to transgender personnel was "relatively low" - between $2.4 million and $8.4 million - which represents a 0.04 to 0.13 per cent increase in healthcare costs.
The study also examined the policies of militaries that were open to transgender personnel, including Australia.
"In no case did the RAND team find evidence of an effect on operational effectiveness, operational readiness or cohesion," the study found.
Former US soldier turned military whistleblower Chelsea Manning, who is a transgender woman, said that Mr Trump's announcement "sounds like cowardice".
so, biggest baddest most $$ military on earth cries about a few trans people 😩 but funds the F-35? 😑 sounds like cowardice 😎💕🌈 #WeGotThis— Chelsea E. Manning (@xychelsea) July 26, 2017
Mr Trump's tweets also drew swift opposition from groups that represent transgender military personnel.
"It's an absolute absurdity and another overstep," said Matt Thorn of OutServe-Servicemembers Legal Defense Network, which advocates for the lesbian, gay, bisexual and transgender community in the military.
He said thousands had been serving in the US armed forces without causing any issues.
Trans/Gender Non-Conforming Justice Project director Victoria Rodriguez-Roldan said the transgender community "will not stop fighting" for justice.
"The military is often the last resort for people who can't find jobs because of discrimination," she said.
The American Civil Liberties Union called Mr Trump's move "outrageous and desperate".
"The thousands of transgender service members serving on the front lines for this country deserve better than a commander-in-chief who rejects their basic humanity," senior staff attorney Joshua Block said.
"Let us be clear. This has been studied extensively, and the consensus is clear: There are no cost or military readiness drawbacks associated with allowing trans people to fight for their country."
The National Center for Transgender Equality said in a statement: "This is worse than 'don't ask, don't tell'; this is 'don't serve, don't serve'.
"This is an appalling attack on our service members; it is about bigotry rather than military readiness, reason or science. It is indefensible and cannot stand."
Human Rights Watch called the ban "repugnant and discriminatory".
"The President's claim on Twitter that this is about saving money on medical costs is laughable. No qualified, capable person should be turned away from service solely because of who they are," the organisation said in a statement.
However, the Family Research Council, a Christian organisation that believes "homosexual conduct is harmful", was supportive of Mr Trump's action.
"I applaud President Trump for keeping his promise to return to military priorities - and not continue the social experimentation of the Obama era that has crippled our nation's military," president Tony Perkins said in a statement.
"The military can now focus its efforts on preparing to fight and win wars rather than being used to advance the Obama social agenda."
Military chiefs put a stop to new transgender people enlisting in the armed forces, imposing a six-month ban in June 2017 to give them time to review the potential impact.
There are concerns among some in the military that transgender troops could have had medical or psychological issues that could hamper their ability to deploy to battlegrounds or meet physical standards.
After Mr Trump's announcement, Twitter reacted incredulously to a tweet from June 2016, before the election, where he vowed to fight for the lesbian, gay, bisexual and transgender community.
Thank you to the LGBT community! I will fight for you while Hillary brings in more people that will threaten your freedoms and beliefs.— Donald J. Trump (@realDonaldTrump) June 14, 2016