(Reuters) - A U.S. appeals court handed President Donald Trump a victory in his effort to ban most transgender people from the military, ordering a judge to reconsider her ruling against the policy, which the U.S. Supreme Court has allowed to take effect.

Demonstrators gather to protest U.S. President Donald Trump's announcement that he plans to reinstate a ban on transgender individuals from serving in any capacity in the U.S. military, at the White House in Washington, U.S. July 26, 2017. REUTERS/Jonathan Ernst - RC12D641E1E0

The 9th U.S. Circuit Court of Appeals on Friday set aside a ruling by U.S. District Judge Marsha Pechman in Seattle, which had said the ban likely violated the constitutional rights of transgender service members and recruits.

Without ruling on the merits, a three-judge panel of the San Francisco-based appeals court said Pechman did not give the military’s judgment enough deference, and ordered her to give it more.

That finding could strengthen Trump’s position, though the government still had the burden of justifying his policy.

Sharon McGowan, legal director of Lambda Legal, which represents opponents of the ban, said she believed the decision foreshadowed the eventual “vindication of the constitutional right of the transgender service members who have been harmed by this policy.”

Pechman is one of four federal judges to rule against Trump’s policy toward transgender military personnel.

In January, the Supreme Court, which has a 5-4 conservative majority, lifted lower court injunctions against the policy, while allowing legal challenges to continue.

Kelly Laco, a spokeswoman for the U.S. Department of Justice, said that agency will continue defending the ban, which lets the Pentagon “continue implementing a personnel policy it determined necessary to best defend our nation.”

Trump, a Republican, announced the transgender ban in July 2017, saying the military needed to focus on “decisive and overwhelming victory” without being burdened by the “tremendous medical costs and disruption” of having transgender personnel.

The move marked an about-face from a landmark policy announced in 2016 by Democratic President Barack Obama, which let transgender people serve without fear of being discharged, and receive medical care to transition genders.

In March 2018, Trump backed a revised policy from then-Defense Secretary Jim Mattis that disqualified most transgender people with a history of gender dysphoria from military service, and people who have undergone gender transition steps.

Medical experts define gender dysphoria as distress from the internal conflict between physical gender and gender identity.

The policy also allowed those military personnel diagnosed with gender dysphoria under Obama’s policy to serve according to their gender identity.

In April 2018, Pechman extended her injunction to the revised policy, finding no evidence that transgender troops reduced the military’s effectiveness, and saying the ban undermined the dignity of those troops.

On Friday, the appeals court said the revised policy “discriminates on the basis of transgender status” but was nevertheless “significantly different” from the 2017 ban.

“On the current record,” the court said, “a presumption of deference is owed, because the 2018 policy appears to have been the product of independent military judgment.”

The government, nevertheless, still bore the burden of showing the policy significantly furthered its important interests, “and that is not a trivial burden,” the court added.

Friday’s decision related to an August 2017 lawsuit by current and aspiring Army and Navy personnel, including one stationed overseas with nearly 20 years of experience. Washington state later joined the plaintiffs.