Navy SEAL accused of killing an injured teenage ISIS prisoner of war in Iraq was freed from custody on Thursday by a military judge as a move to rectify unsanctioned tracking of the defense team's emails.

The judge, Capt. Aaron Rugh, has not ruled yet on whether to throw out the case against Special Operations Chief Edward Gallagher or remove the prosecutors who allegedly attached tracking software to emails they sent to Gallagher's lawyers in a bid to find the source of leaks to the media about the case.

WIFE OF NAVY SEAL EDDIE GALLAGHER SAYS MILITARY PROSECUTORS SHOULD BE INVESTIGATED OVER 'CRIMINAL WRONGDOING'

Gallagher's attorneys accused the prosecutors of misconduct and initially demanded that Rugh be removed from the case. The motion against the judge was withdrawn after it was revealed that  Rugh did not know of the email tracking methods despite condoning finding out who leaked court memos.

Attorney Tim Parlatore accused prosecutors of a "rogue, relentless, and unlawful cyber campaign" that may have violated attorney-client privilege and hurt Gallagher's ability to get a fair trial. Marc Mukasey, another member of Gallagher's legal team, is an attorney for President Trump, who has reportedly considered pardoning the Navy SEAL along with several other military personnel accused or convicted of war crimes, according to The New York Times.

Trump previously got Gallagher removed from the brig and transferred to better custody conditions at a Navy hospital.

CLICK HERE FOR THE FOX NEWS APP

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

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

The Associated Press contributed to this report.