Albert province, through Montana, South Dakota and part of Nebraska, to existing facilities in that last state.
Keystone XL roused a major environmental protest movement during Barack Obama's presidency, leading to arrests outside the White House and promises by activists to harass construction along the pipeline's route.
The judge barred both TransCanada and the U.S. from "from engaging in any activity in furtherance of the construction or operation of Keystone and associated facilities" until the U.S. State Department completes a supplemental review.
Judge Brian Morris of the U.S. District Court in Montana issued the order just as the TransCanada company was moving materials to begin building its end of the $8 billion pipeline in the northern part of the state early next year, reported the Great Falls Tribune.
"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", said Sierra Club Senior Attorney Doug Hayes in a statement.
"This is a significant setback for TransCanada's Keystone XL pipeline project and big win for Indigenous defenders, the environment, and for the thousands of people who have been fighting this pipeline for almost a decade". New tar sands pipeline projects threaten Indigenous rights, put drinking water and communities at risk, accelerate the climate crisis and move us in the wrong direction.
After years of legal wrangling, Obama rejected a permit for the pipeline in 2015. "As the court has made clear yet again, the Trump administration's flawed and risky proposal should be shelved forever".
Work can not proceed until the State Department completes a supplement to the environmental impact statement that complies with the National Environmental Policy Act and the Administrative Procedure Act, Morris ruled. A presidential permit is required for infrastructure projects that cross global borders.
U.S. President Donald Trump called the ruling a disgrace and says it will be appealed.
He said the government's analysis did not fully study the cumulative effects of greenhouse gas emissions, the effects of current oil prices on the pipeline's viability or include updated modeling of potential oil spills.
In 2015, on the eve of the global climate talks in Paris, the Obama administration appeared to bring an end to the seven-year-long saga when it announced it was halting construction of the pipeline, arguing that approval would compromise the country's effort to reduce its greenhouse gas emissions.
Environmental groups who oppose the pipeline and filed the lawsuit say the ruling is a victory for advocates and a significant setback for the pipeline.
McTeague believes Keystone XL has support across the political spectrum in the United States, but it only takes one judge to pause the project. He ordered the department to complete a full review.
"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.