President Donald Trump on Friday announced a new ban on transgender people serving in the military.

In a memo issued late Friday, Trump stated that transgender people “with a history or diagnosis of gender dysphoria” are “disqualified from military service except under certain limited circumstances.”

Trump said that he was basing his ban on the recommendation of Defense Secretary James Mattis.

Mattis made the recommendation after creating a panel “comprised of senior uniformed and civilian Defense Department and U.S. Coast Guard leaders” to study the issue.

“Based on the work of the Panel and the Department's best military judgment, the Department of Defense concludes that there are substantial risks associated with allowing the accession and retention of individuals with a history or diagnosis of gender dysphoria and require, or have already undertaken, a course of treatment to change their gender,” Mattis wrote. “Furthermore, the department also finds that exempting such persons from well-established mental health, physical health, and sex-based standards, which apply to all service members, including transgender service members without gender dysphoria, could undermine readiness, disrupt unit cohesion and impose an unreasonable burden on the military that is not conducive to military effectiveness and lethality.”

After Trump first announced the ban in July on Twitter and ordered the Pentagon to implement it, LGBT rights groups filed four legal challenges to banning transgender troops. In each case, a judge has blocked implementation of the ban.

The Pentagon has said that the military “will still comply with federal court rulings and continue to assess and retain transgender service members.”

The Human Rights Campaign (HRC), the nation's largest LGBT rights advocate, suggested in a statement that Mattis was ordered to justify Trump's ban.

“It's quite clear this is a complete ban, and Secretary Mattis was backed into a corner by the Commander-in-Chief and ordered to come up with a post-hoc justification for this policy that was based on politics, not any sort of assessment of where the country is, where military readiness is and the ability of transgender individuals [serving] openly and honestly in our military,” said David Stacy, director of government affairs at HRC.

Aaron Belkin, director of the Palm Center, which studies transgender people in the armed forces, agreed, saying in a statement that the Pentagon's panel had “distorted the science on transgender health” to justify discrimination.

“Today’s announcement fulfills President Trump’s July 2017 tweet calling for the reinstatement of the transgender military ban,” Belkin said in a statement. “In service to the ideological goals of the Trump-Pence base, the Pentagon has distorted the science on transgender health to prop up irrational and legally untenable discrimination that will erode military readiness. There is no evidence to support a policy that bars from military service patriotic Americans who are medically fit and able to deploy. Our troops and our nation deserve better.”

Mattis' recommendation complicates ongoing ligation, because courts generally defer to military leaders on issues related to the military.