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 - a ruling likely to 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, Judge Michael Fisher wrote in Monday's ruling disqualifying Habba.

The BBC has contacted Habba's office, the White House, and the Department of Justice for comment.

In a joint statement, three lawyers who had challenged Habba's authority - Abbe David Lowell, Gerry Krovatin, and Norm Eisen - asserted that this marks the first time an appeals court has ruled that President Trump cannot usurp longstanding statutory and constitutional processes to insert whomever he wants in these positions.

Habba, 41, first joined Trump's personal legal team in 2021 after reportedly meeting him at his golf club in Bedminster, New Jersey. She represented Trump in his hush-money trial in New York last year, when he was convicted on 34 counts of falsifying business records.

Before Habba took on the role of US Attorney for New Jersey, Trump announced her as his presidential counsellor for his second administration, describing her as unwavering in her loyalty and a tireless advocate for justice.

Monday's ruling may force the justice department to find a new prosecutor to supervise federal criminal cases in New Jersey.

The appellate court's decision came after three men facing criminal charges in New Jersey argued that the prosecutor's appointment was unlawful. A federal judge ruled in their favor in August, and Habba is not the first Trump-appointed US prosecutor to face a legal challenge.

In recent weeks, challenges have also been launched against other Trump-appointed prosecutors, sparking discussions about the legality and validity of these appointments.