A federal judge struck down a regulation that would have required medical providers receiving federal funding to perform abortions and gender transition surgeries regardless of their personal beliefs, a major victory for religious liberty advocates.

A federal court in Texas said that an Obama-era rule that would have required doctors to perform procedures contrary to their consciences violated federal law. District Court Judge Reed O'Connor said the regulation put forward by the Obama administration in 2016 "substantially burdens" the rights of health care staffers under the Religious Freedom Restoration Act (RFRA).

"The Court holds that the Rule, which expressly prohibits religious exemptions, substantially burdens Private Plaintiffs' religious exercise in violation of RFRA," the ruling said. "Though the Court maintains that Plaintiffs were entitled to the preliminary injunction granted in its December 31, 2016 Order, it now concludes that the proper remedy at this stage is vacatur of the Rule."

The decision follows a three-year dispute between the federal government and a coalition of several states and religious health care providers. The court issued a temporary injunction against the rule in December 2016, giving the Department of Health and Human Services two years to reform the regulation. While he acknowledged that the agency had made progress in safeguarding religious liberty, O'Connor said the regulation needed to be struck down entirely.

"Despite HHS's better efforts, the rule remains on the books," he wrote in his decision. "Accordingly, the Court finds that principles of equity and judicial economy favor ruling on the pending motions, allowing the other parties in this case to conclude two years of litigation on these issues."

Religious freedom advocates welcomed the ruling. The Becket Fund, a nonprofit law firm, represented the Franciscan Alliance in the case. Becket senior counsel Luke Goodrich said the existing regulation would have hindered care by forcing physicians and nurses to bow to political pressure, rather than their medical judgment and conscience.

"It is critically important that doctors are able to continue serving patients in keeping with their consciences and their professional medical judgment, especially when it comes to the personal health choices of families and children," Goodrich said in a statement. "Doctors cannot do their jobs if government bureaucrats are trying to force them to perform potentially harmful procedures that violate their medical and moral judgment."

The Trump administration has attempted to advance religious liberty for medical providers by rolling back Obama-era regulations. In May, HHS proposed a new rule securing conscience protections for doctors and other caregivers.