A federal judge on Thursday halted construction of the Keystone XL oil pipeline, arguing that President Donald Trump's administration had failed to adequately explain why it had lifted a ban on the project.
The ruling by Judge Brian Morris of the US District Court for the District of Montana dealt a stinging setback to Trump and the oil industry and served up a big win for conservationists and indigenous groups.
Trump granted a permit for the $8 billion conduit meant to stretch from Canada to Texas just days after taking office last year. He said it would create jobs and spur development of infrastructure.
In doing so the administration overturned a ruling by then president Barack Obama in 2015 that denied a permit for the pipeline, largely on environmental grounds, in particular the US contribution to climate change.
The analysis of a cross-border project like this is done by the State Department.
The same environmental analysis that the department carried out before denying the permit in 2015 was ignored when the department turned around last year and approved it, the judge argued.
"An agency cannot simply disregard contrary or inconvenient factual determinations that it made in the past, any more than it can ignore inconvenient facts when it writes on a blank slate," Morris wrote.
He added: "The department instead simply discarded prior factual findings related to climate change to support its course reversal."
The judge also argued that the State Department failed to properly account for factors such as low oil prices, the cumulative impacts of greenhouse gases from the pipeline and the risk of oil spills.
Thursday's ruling is temporary, and requires the government to do a more thorough review of how the project might affect the climate, cultural resources and wildlife. The Trump administration can appeal to a higher court.
The pipeline is designed to run from tar sand oil fields in Canada's Albert province, through Montana, South Dakota and part of Nebraska, to existing facilities in that last state.
From there it would flow to Oklahoma and on to the Texas Gulf coast.
The US stretch of line that needs to be built would be 875 miles (1,450 km) long.
The pipeline was being prepared by TransCanada. Construction of the US leg had been scheduled to begin next year.
Environmental and indigenous groups sued TransCanada and the State Department in March to halt the project.
One of the plaintiffs, the Sierra Club, welcomed the judge's decision.
"Today's ruling makes it clear once and for all that it's time for TransCanada to give up on their Keystone XL pipe dream," Sierra Club senior attorney Doug Hayes said in a statement.
"The Trump administration tried to force this dirty pipeline project on the American people, but they can’t ignore the threats it would pose to our clean water, our climate, and our communities."