U.S. District Court Judge Brian Morris' ruling late on Thursday came in a lawsuit that several environmental groups filed against the U.S. government in 2017, soon after President Donald Trump announced a presidential permit for the project.
Trump granted a permit that allowed energy firm TransCanada to build the controversial Keystone XL pipeline shortly after taking office.
"This is a complete repudiation of the Trump administration's attempts to evade environmental laws and prioritize oil company profits over clean water and wildlife", said Jared Margolis, senior attorney with the Center for Biological Diversity, which is part of a coalition of environmental and native groups that have attempted to stymie the pipeline.
The administration overturned a ruling by the previous Barack Obama administration in 2015 that denied a permit for the pipeline, largely on environmental grounds.
In Thursday's ruling, Morris ordered the government to issue a more thorough environmental analysis before the project can move forward.
Interested in Keystone XL Pipeline?
Morris found that the USA government's use of a 2014 environmental review to justify issuing a presidential permit for construction of the cross-border pipeline violated the National Environmental Policy Act, the Endangered Species Act and the Administrative Procedure Act. The Obama-appointed judge specifically called out State's disregarding the climate change arguments against the pipeline it had made under Mr. Obama.
Iran's economy to suffer but likely ride out USA sanctions
Oil's slide from a four-year high has been fueled by concerns that faltering emerging market economies and a U.S. Energy Information Administration reported the seventh consecutive weekly increase in U.S. crude stockpiles.
The US$8-billion project would help carry 830,000 barrels of crude a day from Hardisty, about 200 kilometres east of Red Deer, to Steele City, Neb., where it could then move on to refineries in the central USA and Gulf Coast. The Trump administration can appeal to a higher court.
Neither TransCanada nor the State Department could immediately be reached for comment on the ruling. A presidential permit is required for infrastructure projects that cross global borders.
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.
TransCanada, which had been planning the pipeline for much of this decade, had planned to begin construction next year.
Morris ruled the Trump administration "jumped the gun" by pushing forward with the pipeline despite concerns over damage to native American heritage and the resulting release of greenhouse gases.
"And frankly, approving this project would have undercut that global leadership", he said, adding that the "biggest risk" the USA faced was "not acting".
He added: "The department instead simply discarded prior factual findings related to climate change to support its course reversal".
Morris' order does not permanently extinguish hopes Keystone XL will go ahead, but it will require the administration to come up with a better explanation as to why it should proceed.