A United States judge has blocked the construction of the Keystone XL pipeline from Canada to the US.

U.S. District Court Judge Brian Morris has temporarily blocked the construction of the $8 billion pipeline, which was one of the first executive orders the president signed when he entered the White House.

“The major spills that occurred between 2014 and 2017 qualify as significant. The department would have evaluated the spills in the 2014 [environmental review] had the information been available,” wrote Morris.

 The judge ruled that construction could not go ahead until a more thorough review of the impact on the climate, cultural resources and wildlife was conducted and accused the state department of having "discarded prior factual findings related to climate change to support its course reversal".

"An agency cannot simply disregard contrary or inconvenient factual determinations that it made in the past," Judge Morris said, ordering the state department to thoroughly review any environmental impacts the pipeline could have.

“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

“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," Sierra Club senior attorney Doug Hayes said in a statement.

A major victory for environmentalists. Another setback for president Trump.