The Obama administration has had a pretty good week at the Supreme Court, but that changed this morning when the court ruled, 5-4, that the EPA had gone about the process of regulating power plant pollutants incorrectly. The decision is a blow to the administration’s efforts to clean up America’s energy economy.

The decision, written by Justice Antonin Scalia on behalf of the court’s five conservatives, claimed that the EPA hadn’t correctly considered the cost of cracking down on mercury and other toxic pollutants, one of Obama’s signature environmental efforts. “It is not rational, never mind ‘appropriate,’ to impose billions of dollars in economic costs in return for a few dollars in health or environmental benefits,” wrote Scalia. For the time being, the regulation will stay in effect while the case goes back to the D.C. Circuit Court of Appeals. Judges there may order the EPA to conduct additional cost-benefit analyses, or they may rule that the EPA overstepped its authority and strike down the regulation entirely.

Environmental groups expressed their outrage in unison. In a statement, Sierra Club attorney Sanjay Narayan accused the court of placing the public “at risk of unnecessary deaths, asthma attacks, and neurological damage.” Advocates argued that the whole cost-vs-benefits discussion is absurd: Even though the coal industry would have to pay an estimated $9.6 billion a year to clean up its operations, the EPA estimated (belatedly) that the monetary benefits of a healthier population were far greater, from $26 billion to $89 billion per year. And, treatment costs aside, how does one quantify the value of protecting children from mercury poisoning?

On the bright side, the rule may have already had much of its intended effect. Brad Plumer notes at Vox:

Even if the rule does get struck down, however, the practical impact on mercury pollution may be relatively limited. Ever since the rule was finalized back in 2012, electric utilities have spent billions installing scrubbers at coal plants and retiring a number of their oldest units in order to comply. While a handful of coal plants may get a reprieve from this ruling, many of the investments in pollution control spurred by the rule have already gone forward.

As this decision comes in, Congress is moving toward dismantling other aspects of Obama’s environmental agenda. Last week, the House voted to allow state governors to opt out of the Clean Power Plan, Obama’s push to limit CO2 pollution from electric plants. And similar legislation is working its way through the Senate, though Obama would, obviously, veto such a bill. The Clean Power Plan also faces its own slew of legal challenges, which will take years to play out. So it’ll be a long time before we know what Obama’s environmental legacy ultimately looks like.