A federal judge in Montana ruled that William Perry Pendley, the acting director of the U.S. Interior Department’s Bureau of Land Management (BLM), had served illegally for more than a year and blocked him from continuing in the position.

“Pendley has served and continues to serve unlawfully…His ascent to acting BLM director did not follow any of the permissible paths set forth by the U.S. Constitution” or the Federal Vacancies Reform Act of 1998 (FVRA), U.S. District Judge Brian Morris of the District of Montana, wrote in a ruling last Friday.

Morris provided Interior officials 10 days from the order’s date to formally respond.

President Trump in June nominated Pendley for the post, which requires Senate approval. The president then withdrew the nomination after a wave of resistance, particularly from Congressional Democrats. Pendley was criticized for his advocacy for selling federal lands, as well as derogatory comments about Native Americans and dismissals of climate change. Pendley has been functioning as BLM director since July 2019, following his designation by Interior Secretary David Bernhardt.

“Pendley has not been nominated by the president and has not been confirmed by the Senate to serve as BLM director,” Morris said in the ruling. “Secretary Bernhardt lacked the authority to appoint Pendley as an acting BLM director under the FVRA.”

Trump could designate a formal acting BLM director, Morris wrote, but absent that, only Bernhardt “can perform functions or duties of the BLM director.” Morris also ruled that Bernhardt cannot choose another person to run the bureau.

The judge added that “any ‘function or duty’ of the BLM director that has been performed by Pendley would have no force and effect and must be set aside as arbitrary and capricious.”

The Interior Department criticized the order as “outrageous” and said it “betrays long-standing practice.” The department said it would appeal immediately. Officials said under President Obama, Interior’s Mary Kendall, former deputy inspector general, served as acting inspector general for years without Senate confirmation.

Montana Gov. Steve Bullock, who filed the lawsuit in July against Pendley and Bernhardt, applauded the ruling on Twitter. The “ruling is a win for the Constitution, the rule of law, and our public lands. Montanans can rest easy knowing that National Public Lands Day will begin with William Perry Pendley packing his desk and vacating the Director’s Office.”

Bullock is currently running for the Senate in a tight race against Republican incumbent Steve Daines.

BLM has been without a Senate-confirmed director since January 2017, when Neil Kornze left. Five people have since been appointed to the position, but none earned Senate approval.

Morris has a long history of butting heads with the energy industry. He blocked construction of the Keystone XL pipeline in 2018, pending a federal government environmental impact review. Earlier 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. The latter decision put a hold on other new oil and gas pipelines as well.

Most recently, in May, Morris issued a ruling that countered Trump administration efforts to boost oil and gas output from public lands; in doing so, he unwound energy leases on more than 470 square miles in Montana and Wyoming.

Morris ruled in May that 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 one million acres of public lands.