The court blocked any activity furthering the construction or operation until the U.S. State Department completes a supplement to a 2014 environmental impact statement that complies with the National Environmental Policy Act and the Administrative Procedure Act.
Trump granted a permit that allowed energy firm TransCanada to build the controversial Keystone XL pipeline shortly after taking office.
The permit approval followed years of intense debate over the pipeline amid steadfast opposition from environmental groups.More news: India gets United States waiver for development of strategic Chabahar Port in Iran
The ruling is a major victory for environmentalist groups that sued to stop the project and for the Native American tribes that have protested against it for years.
The analysis of a cross-border project like this is done by the State Department.
The groups argued the U.S. State Department violated several acts in issuing a presidential permit for the pipeline without a proper environmental assessment of the changed route.
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.More news: Dead After California Shooting At Popular Nightspot, Police Say
Under President Trump, the State Department wrote "there have been numerous developments related to global action to address climate change, including announcements by many countries of their plans to do so" since the Obama administration's decision two years earlier.
"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.
The privately financed pipeline is projected to stretch 1,179-miles (1,897km) from the oil sands of Canada's Alberta province, through Montana and South Dakota, to rejoin an existing pipeline to Texas. "Today, the courts showed the Trump administration and their corporate polluter friends that they can not bully rural landowners, farmers, environmentalists and Native communities".
One of those litigants in this case, the Sierra Club, cheered the decision on substantive grounds. Construction of the U.S. leg had been scheduled to begin next year.More news: Missouri voters approve minimum wage increase