President Donald Trump's administration cannot impose restrictions barring healthcare providers that receive certain federal HIV-treatment funds from acknowledging the gender identity of their transgender patients or from providing them gender-affirming care, a federal judge ruled on Thursday.

U.S. District Judge William Young in Boston sided with a group of national HIV medical associations and healthcare providers that challenged grant funding conditions imposed by the administration after Trump signed an executive order prohibiting federal funding for what he calls "gender ideology." Those conditions were adopted by a division of the U.S. Department of Health and Human Services for funding provided by the Ryan White HIV/AIDS Program, which was created in 1990 by Congress to provide medical care for low-income and uninsured people living with HIV.

Young, who was appointed by Republican President Ronald Reagan, said the conditions were designed to suppress what the administration considered to be "dangerous ideas" in violation of the U.S. Constitution's First Amendment by penalizing doctors for acknowledging that transgender people exist and referring to their patients by their preferred pronouns, and additionally reflected unconstitutional discrimination on the basis of sex in violation of the Fifth Amendment. "They are based in animus, loathing, and discrimination," Young wrote in the 165-page ruling, issued following a non-jury trial in September in the lawsuit, which was filed by groups including the American Academy of HIV Medicine. "They do not stand for justice — in fact, they defy it. They are contrary to the laws of this nation and cannot continue to stand."

Beginning in March, the Health Resources and Services Administration, a division of HHS that administers the Ryan White program, added funding conditions designed to implement the Republican president's executive order directing the U.S. government to recognize only two sexes, male and female, requiring providers to ensure funding would support activities using "sex-based definitions grounded in biological reality" and not "social or medical experimentation," the lawsuit said. Jose Abrigo, a lawyer for the groups at the LGBTQ rights legal group Lambda Legal, hailed the ruling as a "sweeping merits victory for the plaintiffs," while HHS did not immediately respond to a request for comment. The HIV funding policy change was part of Trump's broader crackdown on the rights of transgender people, including bans on transgender people serving in the military and on passport applicants designating their gender identities, actions the U.S. Supreme Court has permitted.