A federal appeals court has permanently banned Donald Trump’s chief prosecutor in New York from investigations targeting the attorney general who beat him in court, ruling his appointment “unlawful.”

The Second Circuit Court of Appeals ruled 2-1 Friday that John A. Sarcone III, the acting U.S. Attorney for the Northern District of New York, was never lawfully in his post.

The ruling bars Sarcone from both cases brought by New York Attorney General Letitia James that Trump has tried to reverse through the Justice Department — the civil fraud case against the Trump Organization and a separate case against the National Rifle Association.