A U.S. Bankruptcy Court judge on Tuesday approved the agreement that Massachusetts state government made to provide $30 million in advance Medicaid payments to keep a handful of Steward Health Care hospitals here open through August as the company tries to sell them.

Judge Christopher Lopez’s decision, which follows his approval last week of the closures of Carney Hospital in Dorchester and Nashoba Valley Medical Center in Ayer, came after a roughly 25-minute hearing during which an attorney for the bankrupt company provided updates on the process to sell the remaining five Steward hospitals (which cover six campuses) in Massachusetts over the coming weeks.

David Cohen, an attorney from Weil, Gotshal & Manges who represented Steward on Tuesday, told the judge that Medical Properties Trust, the landlord for Steward’s hospitals, has agreed to help facilitate the sale of hospital lands to new buyers.

None of the bidders for Steward’s Massachusetts hospitals made proposals that offered to take on existing lease payments, which Steward said contributed to its financial straits, and Lopez last week granted Steward’s request to reject the master lease for the Massachusetts hospitals.

“We’re pleased to report that significant progress has been made. For one, your honor, MPT, Macquarie and their lender have reached an agreement in principle by which MPT and Macquarie will hand over the real property underlying the debtors’ Massachusetts hospitals to Apollo [Global Management] to help facilitate the sale of such real property to the new operators, the bidders that the debtors are working with to sell the operations to. There are still a few issues to iron out, but that high-level agreement in principle removes a significant hurdle that we were facing when we met with your honor last week,” Cohen said. “Further, significant progress has been made in terms of both the commercial terms and the purchase agreements with respect to the sale of the hospital real property and operations to the bidders for the Massachusetts hospitals, each of which are high-quality local operators.”

Cohen said it was a sign of the “significant progress” being made that Massachusetts state government was “prepared to come to court today and prepared to enter into the funding agreement and advance an initial tranche of funding to the debtors to allow the parties to continue to advance negotiations and sign purchase agreements in the coming days, all with the goal of being back in front of your honor next week seeking approval of such sales.”

Lopez is expected to hold a hearing related to the sales of Good Samaritan Medical Center in Brockton, Morton Hospital in Taunton, St. Anne’s Hospital in Fall River, St. Elizabeth’s Hospital in Brighton, and Holy Family Hospital with campuses in Methuen and Haverhill on Aug. 13.

Cohen also said Steward is close to a deal to sell its physician network, Stewardship Health. He said there was an active bidding process taking place for Stewardship Health and that Steward is “very encouraged by the bids and how the bidding process is playing out, and we do expect to announce a winner very soon.”

“So overall, your honor, a lot of work remains to be done, and we certainly have a lot of wood to chop with respect to the hospitals in Massachusetts, and we do believe we’re making some great progress on the Massachusetts and the Stewardship front,” he said.

Lopez gave his blessing Tuesday to the agreement between Massachusetts and Steward under which the state will provide $30 million in the form of advances on Medicaid funds that the state owes Steward hospitals to help keep the five hospitals afloat until new buyers are officially on board.

Cohen said the advance from the state “is actually critical to giving the debtors the opportunity to facilitate the consensual sale and transition of these hospitals to new operators” and “effectively allows the debtors to neutralize their operating losses in Massachusetts during the month of August.”

Under the agreement that Lopez approved Tuesday, the $30 million is “to be used exclusively to fund the operating expenses of the Massachusetts hospitals,” Cohen said. Massachusetts is to pay roughly $11 million on or around Aug. 9 and another $19 million on or around Aug. 16. Cohen said the first payment was conditioned upon Tuesday’s approval and the second payment is conditioned upon Steward “executing purchase agreements with respect to the hospitals and their underlying property by this Friday, August 9, and the issuance ... by the bankruptcy court of an order to approve any sales with respect to the debtors’ assets by August 15.”

Hugh McDonald, an attorney for Pillsbury Winthrop Shaw Pittman who represented the Executive Office of Health and Human Services and Attorney General Andrea Campbell’s office during Tuesday’s hearing, said the payment agreement “represents the commonwealth’s continued commitment to achieving the transition of these six remaining facilities to new operators.”