President-elect Donald Trump can undo many of President Obama’s executive orders with the stroke of a pen, but rolling back a key new mandate forcing religious doctors and hospitals to perform abortions and transgender surgeries looks to be a much more protracted legal battle.

Many judges have begun to adopt the administration’s expansive interpretation of Title IX and other federal directives barring discrimination on the basis of “sex,” lawyers say, limiting the ability of the president-elect to revoke his predecessor’s policies without help from Congress or the courts.

Now the Department of Health and Human Services has taken Section 1557 of the Affordable Care Act, which prohibits “sex” discrimination in the provision of health care, to mean that hospitals, insurance companies and other health care entities that receive federal funding must cover or perform abortions and sex-reassignment surgeries, even if doing so would violate their religious beliefs.

The rule was finalized in May and was to go into effect on Sunday.

But the legal battle escalated over the weekend when a federal judge in Texas on Saturday blocked the Obama administration mandate one day before it was set to go into effect. U.S. District Judge Reed O’Connor is the same judge who, four months earlier, blocked President Obama’s order compelling public schools nationwide to permit bathroom and locker room access on the basis of gender identity.

In issuing a temporary restraining order Saturday, Judge O’Connor said the Department of Health and Human Services lacked a basis for interpreting Obamacare’s prohibition against “sex” discrimination to apply to other characteristics, including “gender identity” and “termination of pregnancy.”

“Prior to the passage of the [Affordable Care Act] in 2010 and for more than forty years after the passage of Title IX in 1972, no federal court or agency had concluded ‘sex’ should be defined to include gender identity,” Mr. O’Connor wrote in his decision.

The lawsuit was brought by the Franciscan Alliance, a religious health care network that operates 14 hospitals in Indiana and Illinois. It was joined by the states of Texas, Wisconsin, Nebraska, Kentucky, Kansas, Louisiana, Arizona and Mississippi.

Lori Windham, senior counsel at The Becket Fund for Religious Liberty, which represented the Franciscan Alliance, said the medical judgment of doctors, not the decree of government officials, should determine the treatment a patient receives.

She said the government itself does not require coverage of sex-reassignment procedures under Medicare or Medicaid due to concerns over the effectiveness of the surgeries and the fluidity of gender identity in children and adolescents.

The LGBT movement condemned Saturday’s ruling, saying it will endanger transgender people seeking medical treatment.

“Judge O’Connor’s decision to prevent the Department of Health and Human Services from implementing crucial protections for transgender people seeking healthcare services puts thousands of people at risk of marginalization, harassment, and discrimination at a time they are most vulnerable and in need of inclusive, respectful care,” Sarah Warbelow, legal director for the Human Rights Campaign, said in a statement.

The Catholic Benefits Association, a group of Catholic hospitals, dioceses and other entities, filed a separate lawsuit against the HHS rule last week.

Martin Nussbaum, the group’s general counsel, said he hopes Mr. Trump will taking a sweeping approach to his predecessor’s actions, rescinding guidances issued by the Obama administration redefining “sex” to mean “sexual orientation” or “gender identity” in federal antidiscrimination legislation.

“President-elect Trump and his appointees can actually do a lot to help in this area,” Mr. Nussbaum said. “Just as Section 1557 was promulgated by HHS, a new regulation can be proposed, and it can even have an effective date on the day it’s proposed that would undo that particular regulation.”

‘Echo chamber’

But he said there has been an “echo chamber of legal logic” between the executive and judicial branches under Mr. Obama, whereby judges appointed by the president have effectively codified administrative interpretations of law.

He pointed to Gloucester County School Board v. G.G., a case decided earlier this year by the U.S. Court of Appeals for the 4th Circuit in favor of a transgender female student who wishes to use the boy’s restroom at a high school in Virginia.

“That case was decided by three 4th Circuit judges who were appointees of the incumbent president,” Mr. Nussbaum said. “And what they looked at were regulations saying ‘sex’ means ‘gender identity.’ And they said we, the Obama appointees, must defer to the Obama agencies that said ‘sex’ means this, and therefore it became law.

“So that precedent, and some others, cannot be undone simply by an executive action, which is why we made the decision to take this on through judicial action,” he said.

The Department of Education previously interpreted Title IX to mandate access to restrooms and locker rooms at public schools nationwide on the basis of gender identity. That edict was blocked in August by another federal judge in Texas.

Mr. Trump could indirectly influence how federal antidiscrimination laws are interpreted through his judicial appointments — including a vacancy on the U.S. Supreme Court, which earlier this year agreed to take up the Gloucester County case.

The HHS rule is predicated on the notion that, if a doctor or hospital can remove a woman’s uterus in order to treat her cancer, then it must also remove the uterus of a woman who wants to be a man, Mr. Nussbaum said.

“It reasoned in a health care context that if an employer’s health plan covered a hysterectomy for a woman suffering with cancer, it must also cover it for a trans man seeking to erase reminders of this person’s biological sex,” Mr. Nussbaum said. “If a hospital, it reasoned, or physician might reconstruct a man’s genitalia destroyed by an improvised explosive device in war, it must also construct genitalia for a gender-dysphoric woman journeying toward presenting as a man.”

Under the new HHS rule, group health care plans must contain coverage for hormonal treatment, counseling and transition surgeries for those who identify as the opposite sex.

Mr. Nussbaum said at least two member dioceses have already received riders from their insurance companies implementing the regulation. They contain guidelines on sex-reassignment procedures that will now be covered under the dioceses’ insurance plans, including “Clitoroplasty (creation of clitoris),” “Labiaplasty (creation of labia),” “Orchiectomy (removal of testicles),” “Penectomy (removal of penis),” “Urethroplasty (reconstruction of female urethra)” and “Vaginoplasty (creation of vagina).”

The regulation also interpreted Section 1557 of Obamacare as prohibiting discrimination based on “termination of pregnancy.” Mr. Nussbaum said the proscription could be interpreted to require hospitals and doctors to perform abortions.

“Embedded within the regulation is, we believe, a surgical abortion mandate,” he said. “In the federal register ‘sex’ is defined, among other ways, as ‘termination of pregnancy.’ When this was first shown, the [commentators] asked for clarification to ensure that this was not an abortion mandate. None was given when the rule was made final.”

The regulation contains no exemptions for health care providers with religious beliefs.

Douglas G. Wilson, CEO of the Catholic Benefits Association, said the rule not only disregards the religious beliefs of Catholic hospitals, which make up one-sixth of hospital health care in the nation, but strips doctors of any say in determining which procedures are appropriate and which are not.

“Every hospital in our country has a medical staff and is required to have an organized medical staff, and the purpose for that medical staff is primarily and almost solely to ensure patient safety and the quality of care,” Mr. Wilson said.

“And it’s a frightening aspect of this whole initiative that that process has been effectively taken out of the hands of the medical staff and decided by a federal agency, which has now determined who can and can’t do it, who will and won’t do it and who must participate,” he said.