The Supreme Judicial Court on Wednesday did what the Legislature would not, striking down a Baker administration push to facilitate the construction of new natural gas pipeline capacity by allowing utilities pass the cost of pipeline construction on to ratepayers.

In an opinion written by newly retired Justice Robert Cordy, the state's top court said the pipeline tariff would "reexpose ratepayers to the very types of risks that the Legislature sought to protect them" with a 1997 law restructuring the electricity market.

The Department of Public Utilities in October 2015 concluded that it had the authority under existing law to approve long-term contracts by utilities like Eversource and National Grid for the purchase of natural gas that would allow for the cost of pipeline construction to be borne by ratepayers.

By creating incentives for expanded natural gas capacity, energy officials were seeking to limit the state's exposure to price spikes during periods of high consumption when expensive power on the spot market would have to be purchased to meet demand. ENGIE and the Conversation Law Foundation, however, challenged the new rules in court, and one Thursday won their case.

"The department's interpretation of the statute as permitting electric distribution companies to shift the entire risk of the investment to the ratepayers is unreasonable, as it is precisely this type of shift that the Legislature sought to preclude through the restructuring act," Cordy wrote in the court's opinion.

Attorney General Maura Healey, who took the rare step of supporting the plaintiffs in the case over a state agency that she would usually be defending in court, celebrated the decision.

"Requiring electric ratepayers to pay for new natural gas pipeline capacity effectively shifts the risks associated with building these projects to ratepayers, contrary to the state’s policies of the past two decades," Healey said in a statement.

House and Senate lawmakers considered banning the pipeline tax during the Legislature's recently concluded debate over a major renewable energy procurement bill, but ultimately left the Senate-backed ban out of the final compromise legislation signed by Baker last week.