On Monday, U.S. District Judge Colleen Kollar-Kotelly blocked the bulk of President Donald Trump’s ban on transgender military service, ruling that the policy likely violates the Constitution’s guarantee of equal protection. Her decision, if upheld on appeal, will prevent the government from discriminating against transgender individuals who are currently serving in the armed forces, prohibiting the Pentagon from purging trans service members. It will not, however, immediately compel the military to enlist openly transgender people, or to fund gender affirmation surgery for those already serving.

Trump’s trans ban sprang into existence in July, when the president tweeted that the government would not “accept or allow” trans people “to serve in any capacity in the U.S. military.” Trans service members have been allowed to serve openly since June 2016; Trump’s tweets raised fears that the government would expel trans troops who had just recently been invited to come out. The National Center for Lesbian Rights and GLBTQ Legal Advocates & Defenders promptly filed a lawsuit on behalf of several trans troops, alleging a violation of their constitutional rights. Several weeks later, the administration turned Trump’s tweets into a memorandum directing the military to implement the full ban by March 23, 2018.

Kollar-Kotelly, who serves on the U.S. District Court for the District of Columbia, has now thrown that plan into serious jeopardy. Her equal protection analysis is as meticulous as it is historic. The judge held that government actions which discriminate against transgender people must be subject to heightened judicial scrutiny, for two reasons. First, Kollar-Kotelly wrote that transgender people should qualify as a “suspect class” because they face “severe persecution” on the basis of “immutable” traits and often lack the political power to protect themselves. Moreover, the discrimination that transgender people face is invidious and unjustified.

“The court is aware of no argument or evidence,” Kollar-Kotelly wrote, “suggesting that being transgender in any way limits one’s ability to contribute to society. The exemplary military service of plaintiffs in this case certainly suggests that it does not.”

Second, and independent from this question, Kollar-Kotelly held that anti-trans discrimination qualifies as sex discrimination under the Fifth Amendment’s equal protection component and thus requires more searching judicial review. This conclusion aligns with the growing judicial consensus that discrimination on the basis of gender identity always qualifies as sex stereotyping, a form of sex discrimination. Trump’s ban, she explained, excludes trans service members “on the basis of their failure to conform to gender stereotypes.” She continued:

The defining characteristic of a transgender individual is that their inward identity, behavior, and possibly their physical characteristics, do not conform to stereotypes of how an individual of their assigned sex should feel, act and look. A service member who was born a male is punished … if he identifies as a woman, whereas that same service member would be free to join and remain in the military if he was born a female, or if he agreed to act in the way society expects males to act. The [trans ban is] accordingly inextricably intertwined with gender classifications.

As a policy that discriminates on the basis of a suspect classification—either sex or transgender status itself—Kollar-Kotelly subjected the trans ban to intermediate scrutiny, which requires an “exceedingly persuasive justification.” There is, quite obviously, no such persuasive justification here.

In her decision, Kollar-Kotelly first summarized the Justice Department’s defense of the trans ban: that many trans people have a disqualifying mental disorder, waste government funds, and harm “unit cohesion.” Even if these canards were true of some trans people, Kollar-Kotelly wrote, the policy remains “extremely overbroad,” raising the possibility that it is motivated by animus. The government also provides “practically no explanation at all, let alone support, for their suggestion that the presence of transgender individuals may be harmful to ‘unit cohesion.’ ”

More importantly, Kollar-Kotelly held, the government’s reasons for banning trans troops are “not merely unsupported, but [are] actually contradicted by the studies, conclusions and judgments of the military itself.” Kollar-Kotelly then listed the many factors that led the government—in the pre-Trump era—to permit transgender service: the RAND study, which found that trans troops had no adverse effect on effectiveness and cost the military very little; the Department of Defense Working Group to further explore trans service; determinations by each branch that trans troops posed no problem; and a conclusion by then-Secretary of Defense Ash Carter that “the needs of the military were best served by allowing transgender individuals to openly serve.”

“In short,” Kollar-Kotelly concluded, “the military concerns purportedly underlying the President’s decision had been studied and rejected by the military itself.”

Finally, Kollar-Kotelly noted that “the discrimination in this case was certainly of an unusual character,” which raises constitutional red flags. Following years of deliberation by “senior military personnel,” and a smooth shift to an inclusive policy, she writes:

[Trump] abruptly announced, via Twitter—without any of the formality or deliberative processes that generally accompany the development and announcement of major policy changes that will gravely affect the lives of many Americans—that all transgender individuals would be precluded from participating in the military in any capacity.

“These circumstances,” she explained, “provide additional support for Plaintiffs’ claim that the decision to exclude transgender individuals was not driven by genuine concerns regarding military efficacy.” Put differently, the courts must acknowledge what the rest of us well know: The trans ban is an act of politically expedient animus, not rational policymaking.

Kollar-Kotelly’s order prevents the Pentagon from discriminating against trans service members. It does not force the military to allow the enlistment of trans people straightaway; instead, it requires the government to return to the policy that was in place before Trump’s trans ban, which would end the ban on trans enlistment on Jan. 1, 2018. And Kollar-Kotelly did not rule on the question of gender affirmation surgery for service members—which Trump purported to defund—holding that no plaintiff yet had standing to raise that issue.

Still, Monday’s ruling is a considerable victory for transgender troops. It puts the government on notice that courts will not simply rubber stamp Trump’s baseless attacks on trans service members, and it affirms the robust constitutional rights of transgender Americans. The Department of Justice will surely appeal to the left-leaning U.S. Court of Appeals for the District of Columbia Circuit, where it will likely lose again. In the meantime, several similar lawsuits will percolate through the appeals courts. Unless Trump backs down, this policy is likely heading to the Supreme Court. At that point, the justices will have to decide whether blatantly prejudiced presidential whims comport with the Constitution’s guarantee of equality.