President Trump tweeted on Wednesday that “transgender individuals” should not be allowed to serve in “any capacity” in the US military.

“After consultation with my Generals and military experts, please be advised that the United States Government will not accept or allow​ …,” he wrote on Twitter.

“Transgender individuals to serve in any capacity in the U.S. Military. Our military must be focused on decisive and overwhelming …​”​

He finished up by writing: “victory and cannot be burdened with the tremendous medical costs and disruption that transgender in the military would entail. Thank you.”

His comments are a significant change in the stance he took last year during the presidential campaign.

“Thank you to the LGBT community! I will fight for you while Hillary brings in more people that will threaten your freedoms and beliefs,” Trump wrote on Twitter in June 2016.

Reaction to Trump’s tweets criticized the president for rolling back gains made by the LGBT community and faulting him for taking action against the military, even though he received medical deferments from the draft.

The ACLU called it an “outrageous and desperate action” and called for transgender military members to contact their lawyers if they need assistance.

“There is no basis for turning trans people away from our military and the ACLU is examining all of our options on how to fight this. For any trans service member affected by today’s announcement: Please get in touch with us, because we want to hear from you,” the group said.

The Anne Frank Center posted a statement on Twitter, saying they are “sickened.

“This move by President Trump is unconscionable evil,” said Executive Director Steven Goldstein. “Rarely if ever in our nation’s history has a president made a move like this that so drastically reverses the civil rights gains of an oppressed community.”

The Human Rights Campaign called Trump’s action “shameful.”

​”​Threatening 15K currently serving troops who put their lives at risk is unpatriotic and dangerous​,” the group said on Twitter.​

Vets Against Trump blasted Trump’s plan as “discriminatory” and “un-American.”

“You are dishonoring people who, unlike you, actually donned the uniform to serve their nation,” Vets Against Trump wrote on Twitter.

Former “Star Trek” star George Takei, an outspoken activist for LGBT issues, slammed Trump.

“History shall record that you are not only the stupidest, most incompetent president ever, but also the cruelest and pettiest. #Shame,” he wrote on Twitter.

It’s not certain what prompted Trump’s tweetstorm about transgender people in the military, but earlier this month the House narrowly defeated a bill that would have ended allowing the Pentagon to pay for gender transition surgeries and hormone therapy.

The amendment to the defense policy bill introduced by Rep. Vicky Hartzler (R-Mo.) would have prohibited money being spent by the military on medical treatment related to gender transition.

“It makes no sense to create soldiers who are unable to fight and win our nation’s wars,” she said.

Democrats, including Rep. Steny Hoyer and ​House leader Nancy Pelosi, called the measure bigoted.

​Stoyer (D-Md.) accused Hartzler of trying to “politically denigrate” transgender troops.​

​Transgender military members have been able to serve openly since last year, when Defense Secretary Ash Carter ended the ban. ​

​​Last month, Defense Secretary James Mattis extended a deadline by six months for military officials to review whether the policy of allowing transgender individuals to ​enlist will affect the “readiness or lethality” of the armed forces.

​Transgender people already in the military would be allowed to continue​ serving, but no new transgender recruits would be able to join during the review.

​A Rand Corp. study​ ​ found there are between 2,500 and 7,000 transgender service members in the active-duty military.

With wires​