A military judge on Monday removed the prosecutor in the trial of a Navy SEAL accused of war crimes after the defense team accused the attorney of misconduct.

The judge ordered Cmdr. Christopher Czaplak removed from Special Operations Chief Edward Gallagher’s trial after Gallagher’s attorney accused him of spying on their emails, according to court documents.

Gallagher is accused of stabbing a wounded prisoner of war to death in Iraq and shooting unarmed civilians in Afghanistan.

His lawyers have argued that the case should be dismissed because Czaplak allegedly monitored the defense team’s emails in an effort to find the source of leaks to the media.

The defense argued that prosecutors embedded a tracking code in emails sent to them and to a Navy Times journalist who has broken a number of stories about the case.

The military judge on Monday said he did not have the power to rule on prosecutorial misconduct, but said Czaplak was removed because of the possibility of a conflict of interest.

Last week, the judge ordered Gallagher released from custody while he awaits trial.

“Gallagher’s case has been irreparably corrupted by a government campaign of outrageous and illegal conduct,” attorney Tim Parlatore said in the opening motion to dismiss the charges Wednesday. “This prosecution threatens to make an unequivocal farce of our justice system.”

The Navy said it would appoint another attorney to replace Czaplak.

“Chief Petty Officer Gallagher is entitled to a fair trial and the Navy is committed to upholding that principle,” spokesman Brian O’Rourke said.

With Post Wire Services