A federal judge in Washington DC on Sunday ruled that the Trump administration’s appointment of Ken Cuccinelli as the acting head of US Citizenship and Immigration Services was illegal — voiding policies put in place on his watch.

Cuccinelli was “not lawfully” appointed in an end-run around typical protocols at federal agencies, wrote Judge Randolph D. Moss in a 55-page decision, citing the Federal Vacancies Reform Act of 1998.

Deputy Director Mark Koumans took over USCIS on an interim basis in June 2019 — following the resignation of his boss, then-director Lee Francis Cissna, and in accordance with the line of succession.

“Kouman’s tenure, however, was short-lived,” wrote Moss.

Nine days later, Kevin McAleenan, then the acting Secretary of Homeland Security, installed Cuccinelli, 51, in a brand new position — as USCIS’ “principal deputy director” — and changed the department’s order of succession, which effectively “allowed Cuccinelli to leapfrog Koumans,” wrote Moss.

“Under the Appointments Clause of Article II of the Constitution, the President must obtain ‘the Advice and Consent of the Senate’ before appointing any principal officer of the United States,” noted Moss.

It wasn’t immediately clear how the move would affect the standing of Cuccinelli — an outspoken proponent of the president’s hard-line immigration policies — at USCIS or DHS, according to CBS News, which noted that neither agency responded to requests for comment.

Moss did rule, however, that policies instituted during Cuccinelli’s tenure are void.

They include a directive to reduce the amount of time granted to asylum-seekers in “credible fear” proceedings to receive guidance from lawyers, and another blocking extensions to the time migrants get to prepare for crucial interviews.