A federal judge ruled Thursday that President Donald Trump’s former lawyer, Alina Habba, has been unlawfully serving as the the top federal prosecutor in New Jersey since last month.

U.S. District Judge Matthew Brann held that Habba’s term as the interim U.S. attorney ended in July, and the Trump administration’s “novel series of legal and personnel moves” to keep her in the role without getting confirmation from the U.S. Senate didn’t follow procedures required by federal law.

“Faced with the question of whether Ms. Habba is lawfully performing the functions and duties of the office of the United States Attorney for the District of New Jersey, I conclude that she is not,” wrote Chief U.S. District Judge Matthew Brann wrote.

The judge said Habba's actions since July “may be declared void," though he put his order on hold so the Justice Department could appeal.

It wasn’t immediately clear if that meant Habba would remain in charge of the U.S. attorney’s office temporarily, or who would make key decisions in the prosecutor's office if she was sidelined. A message seeking comment was sent to Habba’s office.

In a social media post, Attorney General Pam Bondi said the administration would appeal, saying Habba was “doing incredible work in New Jersey — and we will protect her position from activist judicial attacks.”

If upheld, the ruling could lead to challenges against a handful of other U.S. attorneys who have been similarly installed by the Trump administration without Senate approval after their temporary assignments have expired.

At its core, Brann’s opinion took aim at the administration's strategy of using a string of temporary appointments to allow Trump's favored candidates to bypass the usual requirement that U.S. attorneys be confirmed by the Senate — something that requires a degree of bipartisan support.

“Taken to the extreme, the President could use this method to staff the United States Attorney’s office with individuals of his personal choice for an entire term without seeking the Senate’s advice and consent,” wrote Brann, a Republican appointed to a federal court in Pennsylvania by President Barack Obama.

Brann’s decision came after several people charged with federal crimes in New Jersey challenged the legality of Habba's tenure. They sought to block the charges against them, arguing Habba didn’t have the authority to prosecute their cases after her 120-day term as interim U.S. attorney expired.

Lawyers for one of those defendants applauded the court's ruling.

“Prosecutors wield enormous power, and with that comes the responsibility to ensure they are qualified and properly appointed," attorneys Abbe D. Lowell and Gerald Krovatin said in statement. "We challenged the authority of Alina Habba because her appointment ignored the rules that give legitimacy to the U.S. Attorney’s office. We appreciate the thoroughness of the court’s opinion, and its decision underscores that this Administration cannot circumvent the congressionally mandated process for confirming U.S. Attorney appointments.”

Habba represented Trump in criminal and civil proceedings before he was elected to a second term. She briefly served as a White House adviser before Trump appointed her as a federal prosecutor in March.

Shortly after her appointment, she said in an interview that she hoped to help “turn New Jersey red,” a rare overt political expression from a prosecutor, and said she planned to investigate the state’s Democratic governor and attorney general.

She then brought a trespassing charge, which was eventually dropped, against Newark Mayor Ras Baraka stemming from his visit to a federal immigration detention center. Habba later charged Democratic U.S. Rep. LaMonica McIver with assault stemming from the same incident, a rare federal criminal case against a sitting member of Congress other than for corruption. McIver denied the charges and pleaded not guilty.

Questions about whether Habba would continue in the job arose in late July when her temporary appointment was coming to a close and it became clear that New Jersey's two Democratic U.S. senators, Cory Booker and Andy Kim, would block her nomination.

With her appointment expiring, federal judges in New Jersey exercised their power under the law to replace Habba with a career prosecutor who had served as her second in-command.

Bondi then retaliated by firing the prosecutor installed by the judges and renaming Habba as acting U.S. attorney. The Justice Department said the judges acted prematurely and said Trump had the authority to appoint his preferred candidate to enforce federal laws in the state.

Brann's ruling said the president's appointments are still subject to the time limits and power-sharing rules laid out in federal law.

___

Associated Press writer Alanna Durkin Richer in Washington contributed to this report.