A federal judge on Thursday blocked construction of TransCanada’s $8 billion Keystone XL Pipeline, handing a major victory to environmentalists and dealing a blow to the Trump administration. U.S. District Judge Brian Morris in Montana overturned a permit for the 1,179-mile pipeline’s construction granted by the Trump White House last year, saying the justification given for approving the project was inadequate. Morris took particular issue with the administration’s apparent disregard for climate concerns and criticized the State Department, which analyzed the project, for failing to take into consideration the effect of possible oil spills and the effects of greenhouse-gas emissions. “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 ruling comes after TransCanada began delivering pipe to Montana in preparation to begin construction in 2019. Critics have long argued that an oil spill could taint the water system used by Native American tribes and harm wildlife in Montana, where the pipeline would cover about 250 miles, and potentially contaminate a massive aquifer beneath the Midwest. Construction of the pipeline, which would be used to transport petroleum from Canada to the U.S. Gulf Coast, was rejected under the Obama administration in 2015.