While family and friends were counting down to the new year, I was watching a different kind of countdown—whether doctors and health care providers would be forced to violate their medical judgment and provide procedures, including gender transition services and abortions, under a new government mandate.

The mandate is a 362-page regulation that claims to interpret part of the Affordable Care Act. It was issued in May 2016, and major portions of this mandate would have kicked in on Jan. 1.

Becket Law had asked a Texas court for an order protecting health care providers. It was less than nine hours to midnight when we heard the good news: A Texas court issued an injunction protecting doctors and the families they serve from the mandate.

The court ruling came after eight states, an association of almost 18,000 doctors, and a Catholic hospital system challenged a new federal regulation that requires doctors to perform gender transition procedures on children, even if the doctor believes the treatment could harm the child.

Doctors who followed the Hippocratic oath—the historic medical vow that doctors take to act in the best interest of their patients—would have faced severe consequences, including losing their jobs.

This is a commonsense ruling. The government has no business forcing private doctors to perform procedures on children that the government itself recognizes can be harmful and exempts its own doctors from performing. The ruling ensures that doctors’ best medical judgment will not be replaced with political agendas and bureaucratic interference.

The federal regulation applied to over 900,000 doctors—nearly every doctor in the U.S.—and would have cost health care providers and taxpayers nearly $1 billion.

The government itself does not require its own military doctors to perform these procedures. It also does not require coverage of gender transition procedures in Medicare or Medicaid—even for adults—because the government medical experts that oversee those programs did not believe medical research demonstrates that gender reassignment surgery improves health outcomes, with some studies demonstrating that these procedures were in fact harmful.

But under the Department of Health and Human Services rule developed by political appointees, doctors citing the same evidence and using their best medical judgment in an individual case would have faced potential lawsuits or job loss.

A website about this court case provides leading research on the issue, including guidance the government itself relies on. This research shows that up to 94 percent of children with gender dysphoria will grow out of their dysphoria naturally and live healthy lives without the need for surgery or lifelong hormone regimens.

The government desperately wanted to avoid a court ruling on these facts, telling the Texas court that no injunction was needed. Instead, doctors should wait around to see if they got sued and then see whether the government would agree, based on the circumstances, that they were entitled to protection.

That argument was pretty rich coming from the Department of Health and Human Services, which has spent the last five years fighting lawsuits to limit conscience protections for groups like the Green family, who own Hobby Lobby, and the Little Sisters of the Poor.

In those cases and others, the government has been quick to argue for strict limits on protections like the Religious Freedom Restoration Act and the Church Amendment, which protects providers from having to perform abortions.

Never did the government claim that rulings on the contraceptive mandate should wait until someone brought a lawsuit and the government had time to weigh the issues and pick a side. The court didn’t buy that excuse, instead recognizing that the mandate would create immediate and irreparable harm to doctors nationwide.

This ruling is an across-the-board victory that will ensure that the deeply personal medical decision of a gender transition procedure remains between families and their doctors.

This case was brought jointly by Becket Law—which defended Franciscan Alliance, a religious hospital network sponsored by the Sisters of St. Francis of Perpetual Adoration, and the Christian Medical & Dental Associations—and by the Texas attorney general and the states of Texas, Wisconsin, Nebraska, Kentucky, Kansas, Louisiana, Arizona, and Mississippi.