The Supreme Court of Canada on Thursday returned to provincial authorities the power to make banks and other lenders cover the costs of environmental cleanups if their clients in the oil and natural gas industry go bankrupt.

“Bankruptcy is not a license to ignore rules,” Chief Justice Richard Wagner wrote for the majority. “Insolvency professionals are bound by and must comply with valid provincial laws during bankruptcy.”

The decision overturned lower court rulings that let bankruptcy trustees maximize debt recovery. The rejected procedure excluded costs of abandoning and reclaiming wells and production facilities from calculating distributions of asset sale proceeds to creditors of failed companies.

The Supreme Court scrapped the legal maneuver that favored the lenders. The discarded doctrine defined enforcement agencies such as the Alberta Energy Regulator (AER) as unsecured creditors at the rear of the lineup of claims for asset liquidation sale proceeds.

“A regulator exercising a power to enforce a public duty is not a creditor,” wrote Wagner. “The public is the beneficiary of those environmental obligations; the province does not stand to gain financially from them.”

The Supreme Court ruling ended a two-year fight that threatened to saddle the Alberta government and solvent, tax-paying production firms with big bills for cleaning up after corporate failures resulting from recent lows in oil and gas price cycles.

Up to C$8.6 billion ($6.4 billion) in currently foreseeable environmental liabilities were at stake, said a study by the C.D. Howe Institute. The research estimated that unpaid cleanup costs have accumulated among 155,000 depleted and inactive Alberta wells.

The legal battle blew up over a small example of an industry hard landing. Redwater Energy Corp. subsided into bankruptcy with 72 of its 84 wells out of action and in need of environmental cleanups. Alberta trial and appellate courts upheld a decision by bankruptcy trustee Grant Thornton Ltd. to exclude the cleanup bills from calculating asset sale proceeds for Redwater’s creditors.

“What Alberta has chosen is a licensing regime” for development of provincially-owned resources, “which makes such costs an inherent part of the value of the licensed assets,” Wagner said in reversing the lower court ruling.

“This regime has the advantage of aligning with the polluter-pays principle, a well-recognized tenet of Canadian environmental law,” he added. “The fact that regulatory requirements may cost money does not transform them into debt collection schemes.”