President Trump issued an order late Friday that bans transgender individuals from serving in the armed forces except under “limited circumstances,” reversing an Obama-era policy that allowed transgender troops to serve openly for the first time.

Individuals with a history or diagnosis of gender dysphoria — who identify with a gender other than what they were assigned at birth — are ineligible for military service in most cases, the order says, arguing that they “present considerable risk to military effectiveness and lethality.”

The policy shift, announced late on a Friday evening, hours after Trump had left for a weekend at his golf resort in Florida, is the latest twist in a politically fraught controversy that began unexpectedly last summer when Trump called in a tweet for banning transgender troops, catching the Pentagon off guard.

The new order appears to bar the Pentagon from resuming enlistment of transgender troops and to require kicking out some now-serving troops. However, the order gives Defense Secretary James N. Mattis leeway to retain those who have served openly since doing so was authorized.

Administration officials say the order creates an objective standard for prohibiting transgender individuals from serving — a contention certain to be tested in court.

Three federal district judges have ruled against Trump's original blanket ban, issuing preliminary rulings blocking his directive.

‘We’re Already Here’: A Renewed Transgender Ban Would Kill This Seasoned Army Grunt’s Long Career

‘Don’t Ask, Don’t Tell’ Is Gone, But Its Effects Still Haunt LGBT Veterans

The Pentagon keeps no figures on transgender personnel. Outside groups estimate there are 1,300 to 15,000 transgender troops in the military, which has an active-duty force of about 1.3 million.

“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,” said White House Press Secretary Sarah Huckabee Sanders.

But Trump's effort to bar transgender service members has faced intense pushback in Congress and the courts, raising growing doubts about whether Trump will proceed with his sweeping ban.

It was quickly condemned by outside groups advocating for transgender troops and by Democratic lawmakers in Congress.

“This policy is a thinly veiled and feeble attempt by the Trump-Pence administration to justify the unnecessary discrimination of qualified patriots in order to advance their own personal agendas and in defiance of the administration's top military leadership. This plan is riddled with blatant animus, bigotry, and ignorance but conveniently void of any foundational bases or facts,” said Matt Thorn, president of OutServe-SLDN, an LGBT rights group.

The House Democratic minority leader, Rep. Nancy Pelosi of San Francisco, tweeted: “No one with 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.”

The new ban will apply to transgender individuals who require substantial medical treatment, including medication and surgery.

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 had undergone gender reassignment surgery. 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 difficult for a transgender recruit to qualify. But they closely track conditions imposed by the Obama administration in 2016, when the Pentagon initially lifted its ban on transgender troops serving openly in the military.

Mattis has said that transgender troops would have to be capable of deploying for at least a year to an overseas war zone, the same policy the Pentagon plans to impose on all troops to remain in the military.

It is unclear whether Trump will adopt Mattis' recommendations, which the White House asked for after an abrupt series of Trump tweets last July that called for the Pentagon not to “accept or allow” transgender troops to serve “in any capacity.”

That would reverse the current policy, since 2016, of allowing transgender troops to serve openly.

A major change of Pentagon policy is typically subject to months, if not years, of study and legal vetting before it's rolled out. In his tweet last year, Trump told Mattis a day before he announced the decision on Twitter, and didn't consult senior military commanders beforehand.

The White House gave Mattis until last month to submit a plan on how it would implement the ban, including how it would handle thousands of transgender soldiers, sailors, Marines and airmen now in uniform.

Under the Obama policy, transgender individuals were to be allowed to openly enlist in the military for the first time by Jan. 1, 2018. But Mattis waived that deadline while the entire policy was under review.

In an executive order last year following his tweet, Trump directed the Pentagon to develop guidance on returning to “the long-standing policy and practice” of barring military service by transgender individuals.

But it also let Mattis issue a recommendation on whether self-declared transgender members of the military could continue to serve, which he delivered last month in a private conversation with Trump.

©2018 the Los Angeles Times. Distributed by Tribune Content Agency, LLC.