A U.S. district judge in Montana, who has butted heads with the energy industry in previous high-profile cases, reversed more than 400 oil and natural gas leases over habitat protection concerns for the sage grouse.

In a ruling last Friday that counters Trump administration efforts to boost output from public lands, U.S. District Court Judge Brian Morris in Montana unwound energy leases on more than 470 square miles in Montana and Wyoming.

Morris ruled that the Interior Department’s Bureau of Land Management (BLM) did not do enough to promote development outside of areas with habitat for sage grouse, a ground-dwelling bird whose numbers have dwindled in recent years amid development in the West. Morris said BLM had not properly followed a 2015 federal plan to do so on more than a million acres of public lands.

“The errors here occurred at the beginning of the oil and gas lease sale process, infecting everything that followed,” Morris wrote. This includes all that happened “in the oil and gas lease sales,” including the government’s “analysis of each lease sale, the protests that BLM received and the responses it provided to those protests,” as well as potential expressions of interest that interested parties may have submitted initially.

With the decision, Morris struck down 440 oil and gas leases, meaning officials will have to give back sales proceeds to companies that signed the leases if the ruling holds up on appeal.

“The court recognizes that the government and states will need to return millions of dollars to the interested parties who won lease sales,” and Morris said economic harm did not warrant maintaining the leases.

Supporters and detractors of the ruling said it appeared to directly challenge the Trump administration’s energy policies, though their views on the ruling’s merits vary widely.

Under former President Obama, the BLM largely shelved public land lease sales across several states in the West because of concerns that continued development would further erode grouse populations. To keep the birds off the endangered or threatened list per the Endangered Species Act, a broad plan was adopted, with state support, to protect the habitat from development.

Following President Trump’s inauguration in 2017, the BLM altered that plan, easing some restrictions and rules, including the one prioritizing development outside grouse habitat. Lawsuits from environmental and wildlife groups ensued.

In the latest case decided by Morris, the Montana Wildlife Federation argued that the BLM made decisions when the Obama rules were in effect and then undercut them when Trump took office. Morris agreed.

“The court’s decision is not only good news for the sage-grouse, it reaffirms the historic plan that BLM worked out with farmers, ranchers, conservationists, energy groups, and government officials,” said Earthjustice staff attorney Michael Freeman, who represented the plaintiffs. “It confirms that the Trump administration violated the law in bulldozing those commitments in its haste to sell off lands that are owned by all Americans to the oil and gas industry.”

The industry-backed Western Energy Alliance joined the states of Wyoming and Montana in challenging the case and defending the Trump administration’s changes. Alliance President Kathleen Sgamma said Morris ruled that, in effect, the BLM had not completed its lease sale analyses properly. Even by accepting that argument, she told NGI’s Shale Daily, “the remedy is more analysis, not striking down leases.”

Morris, Sgamma said, “is the definition of an activist, and that is an inappropriate role for a district judge to play. So we really like our chances on appeal.” She also noted that each new administration may alter policies as long as they do so legally, and the Trump administration had done that.

Morris has a storied history with the energy industry. He blocked construction of the Keystone XL pipeline in 2018, pending a federal government environmental impact review. This year Morris halted work on Keystone again as part of a decision to strike down a Nationwide Permit used by the Army Corp of Engineers. That latter decision put a hold on other new oil and gas pipelines as well.