A New York federal judge on Monday stopped the Trump administration from enforcing a new rule that rolls back nondiscrimination protections for transgender patients.

In his 26-page decision, U.S. District Judge Frederic Block issued a preliminary injunction to stop the Department of Health and Human Services (HHS) from enacting the rules, which he said is contrary to the June Supreme Court decision that protects the civil rights of employees based on their gender identity or sexual orientation. The new rule was supposed to take effect on August 18. But HHS acted “arbitrarily and capriciously” in enacting the rules, Block said.

RELATED: Supreme Court landmark ruling protects LGBTQ work rights, days after HHS rolls back transgender health care protections

The Supreme Court ruling came down three days after HHS finalized a rule to “restore the rule of law” and revise Section 1557 of the Affordable Care Act, which bans discrimination in health care, and rolled back protections for LGBTQ patients. The new rule would protect males or females from health care discrimination but not those who are gay or transgender. Section 1557 applies to those who receive federal funding from HHS, the Health Insurance Marketplace, and health programs administered by HHS.

“HHS was apparently confident that the Supreme Court would endorse the Administration’s interpretation of sex discrimination,” Block wrote in his ruling. “Its confidence was misplaced.”

The Human Rights Campaign sued the Trump administration on behalf of two transgender women of color in New York. Tanya Asapansa-Johnson Walker, an Army veteran, is a two-time lung cancer survivor and community leader who co-founded a statewide advocacy group for transgender and gender non-conforming New Yorkers. Cecilia Gentili, an entrepreneur, activist, writer, and storyteller with more than a decade of experience as a patient and health care policy advocate.

HRC President Alphonso David said in a statement that the preliminary injunction is a “crucial early victory” for the entire LGBTQ community.

“We are pleased the Court recognized this irrational rule for what it is: discrimination, plain and simple. LGBTQ Americans deserve the health care that they need without fear of mistreatment, harassment, or humiliation,” he said.

HRC’s lawsuit is one of various challenges to the health care discrimination rule. Lambda Legal and Steptoe & Johnson LLP has also filed a lawsuit in the United States District Court for the District of Columbia, which also seeks reversal of the Trump administration’s aim to eliminate LGBTQ people from Section 1557 of the ACA, as well as the provisions that eliminate access to care for people with Limited English Proficiency (LEP) and allow for health care providers to elevate their own religious interests over the needs of their patients. Oral arguments were heard on August 2 for a preliminary injunction and a decision is pending.

“We applaud today’s decision and look forward to continuing our fight against this rule that unlawfully targets and singles out LGBTQ people for discrimination during their most critical time of need, when seeking health care. Our communities deserve better,” said Lambda Legal Staff Attorney Carl Charles in a statement.