[Editor's note: This story was updated at 9:45 p.m. CT May 26.]

A U.S. judge in Montana has thrown out a Trump administration directive that weakened an Obama-era policy aimed at protecting a threatened Western bird, invalidating hundreds of oil and gas leases on federal land in Montana and Wyoming.

In a ruling issued late on May 22, District Court Judge Brian Morris sided with environmental groups that had challenged the administration's 2018 policy reversal as well as three auctions in Montana and Wyoming in 2017 and 2018 that sold oil and gas leases in sage grouse habitat.

"All of our lease sales are on sound legal footing and in full compliance with" environmental laws, the Bureau of Land Management, the arm of the U.S. Interior Department that oversees oil and gas leasing, said in an emailed statement.

The order was the latest legal blow to U.S. President Donald Trump's effort to increase energy production on federal lands by rolling back environmental regulation. Earlier this month, Judge Morris halted nearly 300 of the same Montana leases, ordering an environmental analysis of the impact of fracking on drinking water.

"The decision here really struck down the administration's basis for sacrificing all that sage grouse habitat for oil and gas leasing," Earthjustice attorney Mike Freeman said in an interview.

Earthjustice filed the lawsuit on behalf of the Montana Wildlife Federation, the Wilderness Society, National Audobon Society, National Wildlife Federation, and Montana Audobon.

The U.S. Bureau of Land Management, the arm of the Interior Department that oversees oil and gas leasing, did not immediately respond to a request for comment.

The order on May 22 threw out a 2018 memorandum issued by Trump's Interior Department that changed how leasing in sage grouse habitat would be prioritized. The policy opened up hundreds of thousands of acres to oil and gas leasing that had been restricted under the Obama plan.