U.S. Bankruptcy Judge Kevin Gross on Thursday approved the sale of Hahnemann University Hospital’s medical residency programs to Thomas Jefferson University Hospitals Inc. for $55 million, a decision criticized as setting a dangerous legal precedent.

Gross called the decision one of those that “cause a judge to lie awake at night.” He ruled in favor of the sale despite objections from regulators overseeing the residency program.

The federal regulator, the Centers for Medicare and Medicaid Services (CMS), considers the sale illegal and warned that the bankruptcy judge’s decision could result in residency slots at distressed hospitals being considered as valuable assets available for sale. Arguably, private equity owners could seize on the ruling as a way to increase the return on their investments.

While finding that the unprecedented sale would be in the best interest of the bankrupt hospital, “the court is compelled to give the government a chance to appeal,” Gross said from the bench. The federal government has seven calendar days to appeal.

The approval of the sale marks a key turning point in the Hahnemann and St. Christopher’s bankruptcy filed June 30, about 18 months after California investment banker Joel Freedman bought the hospitals for $170 million from Tenet Healthcare Corp. Unless the ruling is overturned, it will guarantee that the more than 500 residency slots, paid for by federal funds, would stay in the Philadelphia region.

U.S. Department of Justice Attorney Marc S. Sacks, who represented CMS, asked for a longer-term stay of the ruling, suggesting that Gross’ ruling could inspire struggling rural hospitals to sell resident slots to wealthier areas. “This could open the door to that nationwide,” Sacks said. “This is a serious, significant issue with nationwide implications.”

Gross, as a bankruptcy judge primarily concerned with making sure there is as much money as possible available to pay creditors, overruled Sacks, as he did repeatedly while going over details in the order Gross will issue allowing the sale to happen. Gross called the increase in the price for the residency program from an initial $7.5 million bid to $55 million “a stunning success” for Hahnemann.

The sale order contains controversial language ordering CMS to do things it doesn’t want to do because lawyers for Hahnemann and Jefferson are worried that CMS could torpedo the sale by doing something such as terminating Hahnemann’s Medicare provider agreement before the sale is final. After the sale, CMS could possibly refuse to pay Jefferson for the residents it acquired, a lawyer for Jefferson suggested.

Already on Wednesday, Sacks said that CMS planned to follow procedures established by the Affordable Care Act for distributing residency slots when a teaching hospital closes. That process does not have a place for private sales such as the one Gross approved.

While going through the sale order with Gross and lawyers for Jefferson and Hahnemann, Sacks repeatedly objected to measures that he argued exceeded the bankruptcy judge’s authority.

At one point, Gross said, “I know I’m treading on thin ice, but I’m going to overrule your objection.” On another occasion, Gross said he had to approve certain language in the context of the sale order because “otherwise, what is Hahnemann selling?”

Gross’ approval of the sale was a blow to a nurses union and others who were hoping for a new auction of the hospital as a going concern.

“We’re very disappointed to see Jefferson and an unelected bankruptcy judge finish what Joel Freedman started and shutter an important safety-net hospital,” said a spokesperson for the Pennsylvania Association of Staff Nurses and Allied Professionals, which represented 800 Hahnemann nurses. “We hope the federal government will appeal to prevent this from establishing a truly dangerous precedent.”

The path to Thursday’s decision by Gross started July 10, when officials from Hahnemann, Drexel University, and Tower Health announced the proposed sale of Hahnemann’s residency programs to Tower for $7.5 million as a way to save the current contingent of residents from disruption. They downplayed the long-term implications of the sale, namely the permanent acquisition of Hahnemann’s more than 500 residency slots paid for by Medicare.

Early on, the deal was considered a long shot because the sale agreement made it contingent on CMS’s approval. CMS objected to the sale from the start.

But when the Aug. 8 auction resulted in the surprisingly high price of $55 million, getting the deal approved in bankruptcy court took on new urgency even if federal regulators refused to budge. The sale agreement with Jefferson removed the condition that CMS had to give the deal its blessing, giving Gross one less reason to reject it.

“It seems that the provision of quality patient care and quality of physician education is being over-shadowed by the large amount of money in play,” said Katharine Van Tassel, a visiting professor of law at Case Western Reserve University in Cleveland.

What exactly will Jefferson acquire if it ultimately lays out $55 million for Hahnemann’s Medicare provider agreement and provider number?

Sacks on Wednesday tried to get Jefferson executive vice president Laurence Merlis to concede that Jefferson is attempting to buy permanent residency slots. At Hahnemann, those positions came with more than $50 million in Medicare funding.

When Merlis insisted that Jefferson is purchasing “the residency program assets,” Sack asked him to describe those assets.

“I don’t know in detail,” Merlis said.

When Sacks asked Merlis to identify assets other than the right to receive Medicare funding for the residency slots, the executive couldn’t do it.