A US appeals court has ruled that President Donald Trump's former personal lawyer, Alina Habba, has been unlawfully serving as top federal prosecutor for New Jersey - in a ruling that may affect scores of criminal cases in the state.

The president handpicked Habba for the role of US attorney this year, but a district court rejected her nomination, so the Trump administration installed her in a role that allowed her to fill in on an acting basis.

The appellate judges found on Monday that this tactic, which bypassed confirmation by the US Senate, violated the Federal Vacancies Reform Act.

Habba is the second Trump-appointed prosecutor to be disqualified in recent weeks.

"It is apparent that the current administration has been frustrated by some of the legal and political barriers to getting its appointees in place," one of the appellate judges, Judge Michael Fisher, wrote in Monday's ruling disqualifying Habba.