A federal judge in New York has ruled against President Donald Trump's “conscience rule” for healthcare providers criticized as allowing discrimination based on sexual orientation and gender identity.

U.S. District Judge Paul Engelmayer said that the rule includes “numerous, fundamental and far reaching” violations of the Administrative Procedures Act.

“The Court accordingly vacates HHS's 2019 Rule in its entirety,” Engelmayer wrote in his 147-page ruling.

Engelmayer also concluded that the Department of Health and Human Services (HHS) falsified its reasons for creating the rule.

The government said that the rule was needed because of a “significant increase” in complaints from healthcare providers unsure of the rules for religious exemptions. HHS said that complaints increased from single digits in one year to 358 between November 2016 and the end of fiscal year 2018.

“Indeed the Court has found that HHS's stated justification for undertaking rulemaking in the first place – a purported 'significant increase' in civilian complaints relating to the Conscience Provisions – was factually untrue,” the judge wrote. “Only around 20 complaints implicate any of the conscience provisions.”

Trump announced the rule during a National Day of Prayer speech he delivered in the White House Rose Garden. A final version was announced in May.

Critics of the rule say it protects healthcare workers who refuse to perform abortions based on their religious beliefs and allows such providers to discriminate against the LGBT community.

The Human Rights Campaign (HRC), the nation's largest LGBT rights advocate, called the rule an “attack” on LGBT people.

“The Trump-Pence administration’s latest attack threatens LGBTQ people by permitting medical providers to deny critical care based on personal beliefs,” HRC Government Affairs Director David Stacy said in a statement. “The administration’s decision puts LGBTQ people at greater risk of being denied necessary and appropriate health care solely based on their sexual orientation or gender identity. Everyone deserves access to medically necessary care and should never be turned away because of who they are or who they love.”

Engelmayer is the first judge to rule on the “conscience rule.” At least eight cases challenging the rule are wending their way through the courts.

HHS said that it was reviewing the ruling.