A federal judge in Montana on Thursday blocked all further work on the Keystone XL pipeline, saying the Trump administration had failed to justify its decision to reverse a prior decision by the Obama administration and to approve the tar sands oil delivery project.

It was a striking victory for environmental advocates who have spent over a decade fighting the project to carry tar sands oil from Canada to markets in the United States and had turned the KXL line into a litmus test for climate action.

Environmental advocates, landowners along the pipeline's route and indigenous rights groups hailed the ruling. They called it a major setback—if not a permanent defeat—for the long-contested crude oil pipeline. The Obama administration had determined that the pipeline was not in the national interest, and President Barack Obama had cited its potential climate impact in rejecting it.

Sign up for InsideClimate News Weekly Our stories. Your inbox. Every weekend.

The Trump administration, determined to make the project an early example of its no-holds-barred policy of exploiting fossil fuel resources without regard for climate consequences, had made only a perfunctory review in its quick decision to speed the work along. A full-blown review can take more than a year to complete; several were done in the past decade, producing mainly controversy and delay while sharpening the climate argument against a line that was first disputed because of the risks of spills in sensitive ecosystems.

Environmentalists challenged Trump's hurried approval in court, noting many new factors: the passage of time, the mounting climate crisis, the risks of spills and the changes in oil markets since the project's debut a decade ago.

The Trump administration "simply discarded prior factual findings related to climate change to support its course reversal," wrote Judge Brian Morris of the United States District Court for Montana.

Judge: Government Failed to Follow U.S. Law

The judge's decision underscored the value of the landmark National Environmental Policy Act (NEPA) as a tool for environmentalists at a time when the Trump administration is seeking a wholesale reversal of regulations that limit the use of fossil fuels or reduce the pollution they produce.

The law calls for a full environmental impact analysis of any major federal action, taking into account its cumulative pollution burdens and encompassing the full sweep of its implications, which in recent decades has increasingly meant looking at the resulting buildup of carbon dioxide in the atmosphere.

Without doing that, the Trump administration in 2017 simply overturned the Obama administration's refusal to approve a permit to cross the U.S.-Canadian border, greasing the skids for the 1,179-mile pipeline. Even so, the pipeline project has been held up by court battles, and work has not commenced on its northern section. A southern section, not needing a border permit, was completed years ago.

The Trump administration failed to take a "hard look" at factors including the current, low price of oil, the cumulative effects of greenhouse gas emissions from Keystone and the Alberta Clipper pipeline, a survey of potential cultural resources along the route, and an updated assessment of potential oil spills, the judge ruled.

President Trump on Friday morning called the ruling "a political decision made by a judge. I think it's a disgrace." Trump added that the case will likely be appealed to the Ninth Circuit Court of Appeals and "we're slowly putting new judges in the Ninth Circuit."

TransCanada: Still Committed to Building Keystone XL

"This decision vindicates what we have been saying all along: Trump's approval of this pipeline was illegal, violated environmental laws and was based upon fake facts," said Tom Goldtooth, executive director for the Indigenous Environmental Network, one of several organizations who filed the suit against the U.S. government in 2017.

Terry Cunha, a spokesperson for the pipeline's developer, TransCanada Corp., said the company is reviewing the ruling but plans to continue moving forward on the project. "We remain committed to building this important energy infrastructure project," Cunha said.

Dena Hoff, a Montana farmer and member-leader of the Northern Plains Resource Council, called the judge's latest ruling "a victory for common sense stewardship of the land and water."

"All Americans should be proud that our system of checks and balances can still function even in the face of enormous strains," Hoff said.