NEW YORK (Reuters) - The U.S. Environmental Protection Agency granted a bankrupt Philadelphia oil refining company a reprieve from complying with the nation’s renewable fuel laws, according to a settlement agreement filed on Monday.

The refiner, Carlyle Group-backed Philadelphia Energy Solutions (PES), filed for bankruptcy protection in January and asked a judge to waive some $350 million in compliance costs under the U.S. Renewable Fuel Standard, or RFS.

The EPA and PES agreed on Monday that the refiner would only have to satisfy about half those costs, but would face more scrutiny moving forward, court documents showed. The settlement is facing early opposition from ethanol groups.

The settlement comes amid a fight between powerful corn and oil interests in Washington over the future of the RFS program. President Donald Trump has sought to bring the two sides together in recent weeks to come up with reforms that can lower the cost for refiners without hurting demand for biofuels, wading into an issue that divides two important constituencies.

The PES bankruptcy - and the potential loss of 1,100 jobs in a key electoral state - had fueled calls for change.

The RFS requires refiners to blend biofuels like ethanol into their fuel or buy credits from those who do. PES, which lacks blending facilities, entered into bankruptcy owing 467 million credits from 2016 and 2017, with only 210 million credits in hand, the filing showed.

The EPA said PES could comply with the program by turning over its available credits and would be excused from any shortfall, a huge win for the refiner. It said the deal would cover the company up until the point it exits bankruptcy.

After exiting bankruptcy, PES would have to comply with the law on a semi-annual basis as opposed to annually and submit itself to more EPA scrutiny. It would face penalties for non-compliance with the agreement.

Neither EPA nor PES responded to requests for comment.

PES has blamed its financial woes on the cost of buying the credits.. But Reuters reported that other factors may also have played a role in the bankruptcy, including the withdrawal of more than $590 million in dividend-style payments from the company by its investor owners.

The private equity firm Carlyle Group rescued the refinery from shutting in 2012, putting up $175 million for majority control of the company. The majority of the dividends paid to the Carlyle-led investor group were backed by loans taken against the refinery’s assets.

The deal will be open for public comment for 10 days before it is finalized, and biofuel groups are showing early opposition.

“Under this settlement, it looks like the Carlyle Group gets to keep that cash while avoiding investing in U.S. biofuels and long-term job security for Philadelphia workers. If that’s the case, this is a massive handout,” Brooke Coleman, head of the Advanced Biofuels Council, said.

Bob Dinneen, CEO of the Renewable Fuels Association, said the group was still evaluating the settlement, “but at first blush, this strikes us as rewarding bombast behavior and it sets an extraordinarily bad precedent.”

The case is #18-10122 (KG), in the U.S. Bankruptcy Court for the District of Delaware.