A federal judge in Washington on Monday blocked President Donald Trump from banning transgender people from serving in the U.S. military, handing a victory to transgender service members who accused the president of violating their constitutional rights.

Trump in July said he would ban transgender people from the military in a move that would reverse Democratic former President Barack Obama's policy and halt years of efforts to eliminate barriers to military service based on sexual orientation or gender identity.

The transgender service members sued in August to try to block the ban. U.S. District Judge Colleen Kollar-Kotelly ruled that the plaintiffs were entitled to an injunction halting enforcement of the ban until their case is resolved.

The service members asserted that Trump's policy violated their rights to due process and equal protection under the law under the U.S. Constitution.

Trump signed a memorandum in August that directed the U.S. military not to accept transgender men and women as recruits and halted the use of government funds for sex-reassignment surgeries for active-duty personnel unless the process is already underway.

Kollar-Kotelly said the plaintiffs were likely to succeed in their claims that the ban was unconstitutional because the reasons given for the ban "do not appear to be supported by any facts." She said that other factors, including "the unusual circumstances surrounding the president's announcement" of the ban, weighed in her decision.

FOLLOW NBC OUT ON TWITTER, FACEBOOK AND INSTAGRAM