A federal judge on Thursday suspended the construction of the Keystone XL oil pipeline, arguing that President Donald Trump's government had failed to explain why it had lifted the project ban.
The decision by Judge Brian Morris of the US District Court for the Montana District to deal with the setback stung Trump and the oil industry and gave a big victory to conservationists and indigenous groups.
Trump gave permission for a $ 8 billion channel that was intended to stretch from Canada to Texas just days after taking office last year. He said he would create jobs and spur infrastructure development.
In doing so, the government overturned a decision by President Barack Obama in 2015 who refused permission for pipelines, mostly for environmental reasons, specifically the US contribution to climate change.
Analysis of cross-border projects like this is carried out by the Ministry of Foreign Affairs.
The same environmental analysis carried out by the department before rejecting permits in 2015 was ignored when the department turned back last year and agreed to it, the judge said.
"An agency cannot simply ignore the conflicting or unpleasant factual determinations it made in the past, more than that it can ignore unpleasant facts when he writes on a blank sheet," Morris wrote.
He added: "The department is not just throwing away previous factual findings related to climate change to support just reversals."
The judge also argued that the State Department failed to take into account factors such as low oil prices, the cumulative impact of greenhouse gases from pipelines and the risk of oil spills.
Thursday's decision is temporary, and requires the government to carry out a more comprehensive review of how projects can affect climate, cultural resources and wildlife. The Trump administration can appeal to a higher court.
Pipelines are designed to run from tar sands oil fields in the Canadian Albert province, through Montana, South Dakota and parts of Nebraska, to facilities in the last state.
From there it will flow to Oklahoma and to the coast of Texas Gulf.
The US boundary line will be 875 miles (1,450 km). The rest is in Canada.
Pipes are being prepared by TransCanada. US foot construction is scheduled to begin next year.
Environmental and indigenous groups sued TransCanada and the State Department in March to stop the project.
One of the plaintiffs, the Sierra Club, welcomed Morris's decision.
"Today's decision makes it clear and for all that it's time for TransCanada to give up the dream of their Keystone XL pipeline," said the senior Sierra Club lawyer, Doug Hayes in a statement.
"The Trump administration is trying to force this dirty pipeline project on the American people, but they cannot ignore the threat that will be posed to our clean water, our climate, and our community."
TransCanada submitted a US application to build a Keystone pipeline