In the US, the pipeline would stretch 875 miles through Montana, South Dakota and Nebraska, with the rest continuing into Canada.
The Keystone XL pipeline permit decision was largely in the hands of the State Department, by virtue of its authority to issue "presidential permits" for cross-border infrastructure projects.
Judge Brian Morris, of the US District Court for the District of Montana, said construction could not go ahead until a more thorough review of the impact on the climate, cultural resources and wildlife was conducted.
The same environmental analysis that the department carried out before denying the permit in 2015 was ignored when the department turned around past year and approved it, the judge argued.
Morris, a former clerk to the late Chief Justice William Rehnquist, was appointed to the bench by President Barack Obama.
Environmental and indigenous groups sued TransCanada and the State Department in March to halt the project. Both pipelines have drawn significant public backlash, with activists arguing that the oil spills could pollute downstream water sources.
"The Court enjoins Federal Defendants and TransCanada from engaging in any activity in furtherance of the construction or operation of Keystone and associated facilities", the court document reads, "until the Department has completed a supplement to the 2014 SEIS (Supplemental Environmental Impact Statement) that complies with the requirements of NEPA and the APA".
Facebook Messenger is finally going to introduce a lifesaving 'unsend' feature
Facebook , who owns WhatsApp , plans to implement the "unsend" feature into the company's Messenger app. According to reports, the feature can only be used within 10 minutes of sending the message.
TransCanada Corp's almost 1,200-mile pipeline has become one of the major battlegrounds in the climate change debate and, if completed, would carry an estimated 800,000 barrels per day from Canada's tar sands pits to Gulf Coast refineries in the US.
But the Trump administration dismissed environmental objections as roadblocks and claimed that there were "numerous developments related to global action to address climate change" in the years since Obama-era rejection of the project.
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 United States contribution to climate change.
One of the plaintiffs, the Sierra Club, welcomed the judge's decision. "The Department appears to have jumped the gun".
"An agency can not simply disregard contrary or inconvenient factual determinations that it made in the past", Judge Morris said in his ruling. He also demanded that the State Department provide a "reasoned explanation" for the turnaround.
Stephan Volker, an attorney for the complainants', called Morris' ruling "a landmark".