The Justice Department released a memorandum Wednesday defending the legality of President Trump’s appointment of Matthew G. Whitaker as acting attorney general, rejecting criticism from some lawyers that the move violates the Constitution.

Since the announcement last week, some have charged that Whitaker, who served as the chief of staff to the previous attorney general, Jeff Sessions, is ineligible to serve as head of the Justice Department because he is not a Senate-confirmed official.

On Tuesday, Maryland Attorney General Brian E. Frosh, a Democrat, asked a federal judge to block Whitaker’s appointment, arguing that Deputy Attorney General Rod J. Rosenstein should instead take on the role.

The Justice Department’s Office of Legal Counsel, which provides legal guidance to the federal government, said in a 20-page memo that past practice, court rulings and legal analysis show the Whitaker appointment is legal. In particular, it says the scenario is expressly authorized by the 1998 Federal Vacancies Reform Act.

The memo also notes that before Sessions was forced out of the job, the White House had sought advice from the OLC and was told that Whitaker could be appointed.

“As all three branches of government have long recognized, the president may designate an acting official to perform the duties of a vacant principal office, including a Cabinet office, even when the acting official has not been confirmed by the Senate,” the memo said.

The memo notes that Trump has now done it six times, while President Barack Obama did it twice and that President George W. Bush did it once.

Interestingly, the legal opinion also concludes that even if Trump had fired Sessions, he could have replaced him with a non-Senate-confirmed government employee for a period of up to seven months, or more if a nomination was pending. By that reasoning, the president has the power to remove Cabinet-level officials at will and put their replacements in charge of major government branches for half a year or more.

Critics of the Whitaker selection have argued that the Federal Vacancies Reform Act should not take precedence over other statutes and the Constitution’s formula for replacing senior government officials.

Trump tapped Whitaker to serve as acting attorney general last week after Sessions resigned at the president’s request. Whitaker’s elevation has raised concerns about his qualifications, his past statements as a U.S. Senate candidate and his business practices.

The OLC’s legal analysis of the practice found 160 such instances — all of them occurring before 1860 — in which a non-Senate-confirmed official became the acting head of an agency. In 1866, a non-Senate-confirmed assistant attorney general served as an acting attorney general, according to the memo signed by Assistant Attorney General Steven A. Engel.

Concerns about Whitaker’s appointment stem partly from unanswered questions about what, if anything, the new acting attorney general may do to try to steer the ongoing probe of Russian interference in the 2016 election. The investigation has also focused on whether any Trump associates conspired with Russia to interfere with the election.

That probe, led by special counsel Robert S. Mueller III, has been supervised by Rosenstein, the No. 2 Justice Department official, because Sessions had recused himself from the case when he was attorney general.

Whitaker, according to people close to him, has no intention of recusing himself from the Russia probe, although Justice Department officials have said he will follow normal department procedures for any possible ethics issues.

Concerns about the Russia probe’s independence have prompted renewed efforts in Congress to pass legislation that would prevent Mueller from being fired without good cause.

On Wednesday, Sen. Jeff Flake (R-Ariz.) said he would not vote for any judicial nominations until Senate leaders allowed a floor vote on legislation he is pushing that would bar the administration from firing Mueller without good cause.

Flake’s position could prevent confirmation of any judges until a new congressional session begins in January, when he will leave the Senate.