ASSOCIATED PRESS Trump's choice of Matthew Whitaker to run the Justice Department is under attack in the courts.

President Donald Trump’s appointment of Matthew Whitaker as acting attorney general was challenged Friday in a surprise motion calling on the Supreme Court to substitute Deputy Attorney General Rod Rosenstein instead.

Veteran Supreme Court litigator Thomas Goldstein argues that Whitaker — a Trump loyalist who was appointed to his post by the president last week — cannot take over for ousted Attorney General Jeff Sessions because Whitaker hasn’t been confirmed by the Senate.

The unusual vehicle for the challenge is a gun rights lawsuit that was initially filed against Sessions in his former capacity as attorney general. Goldstein is asking the justices to determine who should now be the valid defendant in the case — and many other pending cases directed at the federal government’s top law enforcement official.

“This is the extraordinary case in which the identity of the successor is both contested and has important implications for the administration of justice nationally,” the motion states.

Goldstein contends that federal law requires that the Senate-confirmed deputy attorney general ― Rosenstein ― should automatically take over when the attorney general’s office is vacant. Whitaker was serving as Sessions’ chief of staff, a post that was not Senate-confirmed.

Goldstein also filed a motion in federal court earlier this week challenging Whitaker’s appointment on behalf of Maryland Attorney General Brian Frosh (D), The Washington Post reported. It too argued that Rosenstein be installed in Whitaker’s place.

Whitaker is under pressure to recuse himself from anything to do with the ongoing investigation into possible Russian collusion by the Trump campaign. He previously expressed disdain for the probe by special counsel Robert Mueller.

The Justice Department’s Office of Legal Counsel has issued an opinion supporting Trump’s authority to appoint Whitaker.

The lawsuit linked to Friday’s challenge was brought by Barry Michaels, a Nevada man convicted of securities fraud two decades ago, who wants the Supreme Court to rule that people convicted of certain non-violent felonies should not lose the right to own a gun. It’s not clear when the justices will respond to the motion challenging Whitaker’s appointment.

The story has been updated with information about the underlying lawsuit.