BILLINGS, Mont. (AP) — A federal judge on Friday ruled that the Trump administration failed to consider potential damage to the environment from its decision to resume coal sales from U.S. lands, but the court stopped short of halting future sales.

U.S. District Judge Brian Morris in Montana said Interior Department officials had wrongly avoided an environmental review of their action by describing it "as a mere policy shift." In so doing, officials ignored the environmental effects of selling huge volumes of coal from public lands, the judge said.

The ruling marks another in a string of judicial setbacks for President Donald Trump's attempts to boost North American energy production.

A previous order from Morris blocked the proposed Keystone XL pipeline that would transport crude from Canada's oil sands. Other courts have issued rulings against the administration's plans for oil and gas leasing and coal mining.

More than 40 percent of U.S. coal is mined from federal lands, primarily in Western states. Companies have mined about 4 billion tons of coal from federal reserves in the past decade, contributing $10 billion to federal and state coffers through royalties and other payments.

The Obama administration imposed a moratorium on most federal coal sales in 2016. The move followed concerns that low royalty rates paid by mining companies were shortchanging taxpayers and that burning the fuel was making climate change worse.

President Donald Trump lifted the moratorium in March 2017 as part of his efforts to revitalize the slumping coal industry.

"The moratorium provided protections on public lands for more than 14 months," Morris said in Friday's 34-page order. He added that lifting the moratorium was a "major federal action" sufficient to trigger requirements for a detailed analysis of its environmental impacts.

Morris ordered government attorneys to enter negotiations with states, tribal officials and environmental groups in order to determine the next steps in the case.

"The court held clearly that the Trump administration needs to rationally consider the consequences of its decision. Those include dire impacts to clean water, public health and our climate," said Earthjustice attorney Jenny Harbine, who represents environmental groups and the Northern Cheyenne Tribe, which had sued to stop the lease sales.

The attorneys general of California, New Mexico, New York and Washington, all Democrats, also had sued over the resumption of the federal coal lease program. They said it should not have been revived without studying what's best for the environment and for taxpayers.

Interior Department spokeswoman Faith Vander Voort said the agency is reviewing the ruling.

In February, Interior officials had announced a sale of coal leases on public lands in Utah by issuing a statement headlined "The War on Coal is Over." They said the sale would not have been possible if the administration had not overturned the moratorium.

The department's Bureau of Land Management administers about 300 coal leases in 10 states. Most of that coal — 85 percent — comes from the Powder River Basin in Wyoming and Montana. Other states with significant federal coal reserves include Colorado and New Mexico.

Production and combustion of coal from federal lands accounted for about 11 percent of U.S. greenhouse gas emissions in 2014.