A US court on Friday ruled in favor of a Trump administration policy barring certain transgender people from serving in the armed forces, handing the president his first legal victory on the issue after several defeats.

The US court of appeals for the District of Columbia circuit overturned a decision by a federal judge in Washington DC that blocked the policy, saying it probably violates the constitutional rights of transgender recruits and service members.

Donald Trump announced in March that he would endorse a plan by the former defense secretary, Jim Mattis, to restrict the military service of transgender people diagnosed with a condition called gender dysphoria.

The appeals court victory is limited because other federal courts issued injunctions against the policy, which applied nationwide. The administration has asked the US supreme court to weigh in on the issue.

The supreme court is due to consider whether to hear three separate government appeals at its private conference on 11 January.

The various injunctions allowed transgender troops to join the ranks as of 1 January 2018.

“Today’s ruling is a devastating slap in the face to transgender service members who have proved their fitness to serve and their dedication to this country,” said Shannon Minter, legal director of the National Center for Lesbian Rights, one of the groups challenging the policy.

The three-judge panel said in an unsigned opinion that district court judge Colleen Kollar-Kotelly was wrong to conclude that the new restrictions were essentially the same as the original ban, which she had also blocked.

“It was clear error to say there was no significant change,” the judges wrote in the ruling.

The new plan, for example, “appears to permit some transgender individuals to serve in the military consistent with established military mental health, physical health and sex-based standards”, the court said.

The American Psychiatric Association defines gender dysphoria as a “clinically significant distress” due to a conflict between a person’s gender identity and their sex assigned at birth. Not all transgender people suffer from gender dysphoria, according to the association, which opposes a military ban.

The gender dysphoria restriction replaced an outright ban on transgender service members, which Trump announced in July 2017 on Twitter.

Trump’s move reversed Democratic former president Barack Obama’s policy of allowing transgender troops to serve openly and receive medical care to transition.