President Trump released an order Friday night banning most transgender troops from serving in the military except under "limited circumstances," following up on his calls last year to ban transgender individuals from serving.

The White House said retaining troops with a history or diagnosis of "gender dysphoria" — those who may require substantial medical treatment — "presents considerable risk to military effectiveness and lethality."

Mr. Trump surprised the Pentagon's leadership in a 2017 tweet when he declared he would reverse an Obama-era plan to allow transgender individuals to serve openly. His push for the ban has been blocked by several legal challenges, and four federal courts have ruled against the ban. The Pentagon responded by allowing those serving to stay in the military, and began allowing transgender individuals to enlist beginning Jan. 1.

"This new policy will enable the military to apply well-established mental and physical health standards - including those regarding the use of medical drugs - equally to all individuals who want to join and fight for the best military force the world has ever seen," White House Press Secretary Sarah Huckabee Sanders said Friday.

Get Breaking News Delivered to Your Inbox

The new policy was promptly assailed by congressional Democrats and civil rights groups. House Democratic leader Nancy Pelosi tweeted, "No one with the strength & bravery to serve in the U.S. military should be turned away because of who they are. This hateful ban is purpose-built to humiliate our brave transgender members of the military who serve with honor & dignity."

Rep. Ted Lieu, D-California, tweeted about the "stupid bigotry from @realDonaldTrump," writing, "As a veteran who served on active duty, we focused on the mission. We didn't care if you were transgender, bald, gay, or had freckles. No evidence a trans sniper is less accurate or a trans pilot is less effective."

As a veteran who served on active duty, we focused on the mission. We didn't care if you were transgender, bald, gay, or had freckles. No evidence a trans sniper is less accurate or a trans pilot is less effective. Stupid bigotry from @realDonaldTrump.#ProtectTransTroops https://t.co/dCKzfhYtjV — Ted Lieu (@tedlieu) March 24, 2018

Democrats on the House Armed Service Committee said that the president's decision is "vicious, inhumane and utterly wrong," and they pointed out, "There are scores of transgender men and women serving in the military right now, under a policy that had already been established & vetted by DOD and validated by the courts."

.@realDonaldTrump decision to ban transgender military service is vicious, inhumane, and utterly wrong. There are scores of transgender men and women serving in the military right now, under a policy that had already been established & vetted by DOD and validated by the courts. — House Armed Services (@HASCDemocrats) March 24, 2018

The Human Rights Campaign, the nation's largest LGBT civil rights organization, accused the Trump administration of pushing "anti-transgender prejudices onto the military."

"There is simply no way to spin it, the Trump-Pence Administration is going all in on its discriminatory, unconstitutional and despicable ban on transgender troops," said HRC President Chad Griffin.

Joshua Block, a senior staff attorney at the American Civil Liberties Union LGBT & HIV Project, said the policy "effectively coerces transgender people who wish to serve into choosing between their humanity and their country, and makes it clear that transgender service members are not welcome."

Trump received recommendations from Defense Secretary Jim Mattis in February for dealing with transgender individuals serving in the military. The White House said Mattis and Homeland Security Secretary Kirstjen Nielsen agreed with the policy.

Earlier Friday, Maj. David Eastburn, a Pentagon spokesman, said the announcement of a new policy would have no immediate practical effect on the military because the Pentagon is obliged to continue to recruit and retain transgender people in accordance with current law.

The issue has become mired in a complicated string of political statements, court decisions and policy reviews since Trump first stunned his administration with his tweets last July. It's unclear how much impact the court decisions will have on Trump's decision. Activist groups had worried the administration could enact such strict enlistment and health care restrictions that it would become all but impossible for transgender troops to join or continue serving.

Under guidelines presented in December, the Pentagon could disqualify potential recruits with gender dysphoria, those with a history of medical treatments associated with gender transition and those who underwent reconstruction. Such recruits could be allowed in if a medical provider certified they've been clinically stable in the preferred sex for 18 months and are free of significant distress or impairment in social, occupational or other important areas.

Transgender individuals receiving hormone therapy must be stable on their medication for 18 months.

The requirements make it challenging for a transgender recruit to pass. But they mirror conditions laid out by President Barack Obama's administration in 2016, when the Pentagon initially lifted its ban on transgender troops serving openly in the military.