The U.S. Bankruptcy Court on Wednesday approved a settlement allowing Philadelphia Energy Solutions to pay a small portion of the millions of dollars it owes in unpaid renewable energy obligations, clearing a major obstacle facing the bankrupt South Philadelphia refinery’s reorganization.

Under the settlement with the Environmental Protection Agency, PES will pay up to $10 million to buy renewable energy credits, called RINs, to satisfy its regulatory liability. Under a previous agreement, the EPA had capped its claim at $35 million.

U.S. Bankruptcy Judge Laurie Selber Silverstein, whose court is in Wilmington, approved the settlement Wednesday during a brief hearing conducted by teleconference to comply with coronavirus pandemic restrictions.

Under the Renewable Fuel Standard, refiners are required to blend biofuel, such as ethanol, into gasoline. Alternatively, merchant refiners such as PES can buy credits for each gallon of ethanol that others blend into their fuels. Retail gasoline typically contains about 10% ethanol.

This wasn’t the refinery’s first escape from its obligations to pay renewable fuel liabilities, which the company has long complained were an onerous burden that contributed to its financial woes.

The EPA had previously waived about $350 million in biofuels compliance costs for PES after its initial bankruptcy in 2018. That deal allowed PES to exit bankruptcy before a disastrous 2019 fire triggered the refinery’s closure last June.

Ethanol producers, who sell the renewable credits, had objected in the first bankruptcy that allowing PES off the hook would undermine the Renewable Fuel Standard, which is aimed at bolstering the biofuels industry.

The EPA, in a court filing Monday, said it agreed to the settlement rather than insisting on full payment in order to avoid scuttling the refinery’s reorganization. If PES were forced to liquidate rather than go through an orderly reorganization and sale, cleanup plans for the site could be imperiled, it said.

“Liquidation of the refinery facility would have potential negative consequences both under bankruptcy law and under other environmental laws,” the agency said. “Cleanup and responsible stewardship of the refinery facility by a reorganized debtor would have been lost, which would have had threatened negative consequences for the environment and surrounding community.”

Under the refinery’s reorganization plan, the 1,300-acre property will be sold for $252 million to Hilco Redevelopment Partners of Chicago. The closing of that sale, originally scheduled to occur by May 31, has been delayed in part because of logistical challenges caused by the pandemic, according to sources.

PES, which was the largest refinery on the East Coast, needed to buy renewable credits representing 161.8 million gallons of ethanol. The credits, which are traded on open markets, would cost about $78 million to buy at current prices, according to the Oil Price Information Service. So the $10 million that PES is obligated to pay under the settlement is a steep discount to the cost it could have faced.

The settlement would require PES to buy $12 million more renewable credits if the refinery is successful in its current claim for a refund of federal fuel excise taxes. The obligation to pay any additional amount will fall to a liquidation trust that will take over management of the refinery’s remaining business affairs after the real estate is sold.