The military prosecutor of a decorated Navy SEAL accused of murdering a wounded teenage ISIS prisoner in Iraq was booted from the case by a military judge Monday over unsanctioned tracking of the defense team's emails.

Capt. Aaron Rugh ordered Cmdr. Christopher Czaplak removed from the case after lawyers for Special Operations Chief Edward "Eddie" Gallagher accused prosecutors of attaching tracking software to emails sent to them and a Navy Times journalist in a bid to find the source of leaks to the media. In his ruling, Rugh said it was not in his power to determine prosecutorial misconduct, but there was the possibility of a conflict of interest that required Czaplak to be removed.

It was not immediately clear how Rugh's decision would affect Gallagher's trial, which is scheduled to begin June 10. The judge has not ruled on whether to dismiss charges of murder and attempted murder against Gallagher.

Navy spokesman Brian O'Rourke told The Associated Press that Czaplak would be replaced with another attorney.

"Chief Petty Officer Gallagher is entitled to a fair trial and the Navy is committed to upholding that principle," O'Rourke said. The defense team has said that even if a new prosecutor is named, Gallagher can't get a fair trial.

It is extremely unusual for a military judge to remove the prosecution or dismiss a case only days before the start of a trial. Rugh ordered Gallagher released from custody last week after the email tracking came to light.

NAVY SEAL EDDIE GALLAGHER RELEASED FROM CUSTODY AHEAD OF MURDER TRIAL

At a hearing on the matter Friday, prosecutor Lt. Scott McDonald claimed the tracking effort was to collect data such as IP addresses, which have no expectation of privacy, and was not meant to snoop on the content of the emails.

"We're talking about raw data," said McDonald, who argued that "even if there was some intrusion" in violation of attorney-client privilege, it didn't rise to the level necessary to dismiss the case.

WIFE OF NAVY SEAL EDDIE GALLAGHER SAYS SHE, CHILDREN 'HAD A GOOD, LONG CRY' AFTER HUSBAND'S PRE-TRIAL RELEASE

But, Rugh chided Navy investigators who refused to testify Friday about who authorized the tracking scheme, saying the "lack of candor or cooperation in this process, I think, could be huge as a sign of culpability." The defense discovered the tracking code hidden in a suspicious logo of an American flag with a bald eagle perched on the scales of justice beneath Czaplak's signature.

Rugh indicated Friday he was misled about the tracking effort. He said investigators told him privately they planned to embed code in what he believed to be a court document to help them find the source of leaks but the judge said he didn't have the power to authorize such a tactic and wasn't told they planned to target emails sent to the defense lawyers or a journalist.

Gallagher is accused of stabbing to death a 15-year old ISIS fighter in Iraq in 2017, shooting two civilians in the same year and opening fire on crowds, all charges to which he has pleaded not guilty.

CLICK HERE TO GET THE FOX NEWS APP

His platoon supervisor, Lt. Jacob Portier, has been fighting charges of conduct unbecoming an officer for allegedly conducting Gallagher's re-enlistment ceremony next to the militant's corpse.

The case has drawn the attention of President Trump, who reportedly has considered pardoning Gallagher along with other U.S. troops accused or convicted of war crimes.

Fox News' Vandana Rambaran and The Associated Press contributed to this report.