WASHINGTON — A federal court on Monday ruled President Donald Trump cannot act to force transgender service members out of the ranks, a move which critics have repeatedly assailed as unconstitutional.

The decision from the U.S. District Court for the District of Columbia may also open the door for those already serving transgender troops to resume medical services at the government’s expense, a benefit administration officials were working to end in recent months.

The move comes two months after Pentagon officials said that transgender individuals in the ranks could continue to serve pending a Defense Department study of the issue, expected to be completed in early 2018.

Monday’s court ruling overtakes that, freezing in place the military’s transgender policy as of late June.

The department review will still have an effect on whether new transgender recruits can join the military, and what benefits will be available to them. But the findings will not govern whether administration officials can dismiss transgender troops who are already serving, unless another court order overturns this one.

In the ruling, U.S. District Judge Colleen Kollar-Kotelly wrote Monday that transgender members of the military who had sued over the changes were likely to win their broader legal battle on the issue, necessitating the court action.

Advocates hailed the news as a significant win for their efforts to battle what they see as Trump’s discriminatory policies.

“This preserves military readiness,” said Aaron Belkin, executive director of the Palm Center. “We already have an inclusive policy that promotes readiness by allowing these individuals to serve. The courts are now recognizing what the president was trying to do may be unconstitutional.”

In a series of early morning tweets in July, Trump offered a significant change in military personnel policy by saying that the military would no longer “accept or allow transgender individuals to serve in any capacity in the military.”

The announcement came about nine months after former President Barack Obama’s administration allowed transgender individuals to serve openly for the first time, and offered medical services for gender dysphoria treatments and gender reassignment surgery for the first time.

Military officials were scheduled to allow new transgender recruits to join the armed forces, but Defense Secretary Jim Mattis at the start of the summer announced a delay in that policy change to give more time for a force readiness review.

Since that announcement came before the court’s prescribed policy freeze date, the action will not impact those potential recruits. But already serving transgender troops will be able to continue service and receive medical benefits as long as the ruling stands.

At least five other lawsuits are pending in various courts against the proposed ban. In a statement, officials from the American Civil Liberties Union praised Monday’s ruling as “the first decision striking down President Trump’s ban, but it won’t be the last.”

Officials from the American Military Partner Association called the decision more reinforcement that anyone who meets physical fitness standards for the armed forces should be allowed to serve.

“This judge’s decision to block President Trump’s shameful transgender ban gives our military families hope that justice will ultimately prevail,” AMPA President Ashley Broadway-Mack said in a statement.

“More than a year ago, the Department of Defense assured transgender service members it was safe to come out, and it’s unconscionable that President Trump is now targeting them for discrimination.”

A recent Military Times poll of active-duty troops found more than half approved of Trump’s plans to reverse the transgender military policies, but another 24 percent of respondents strongly disapproved of the move.