SAN DIEGO – The military judge presiding over the court-martial of a U.S. Navy SEAL charged with war crimes said on Friday prosecutors who electronically tracked email communications of defense lawyers without a warrant violated the accused’s right to a fair trial.

The finding came near the end of a two-day hearing that wrapped up just 10 days before Special Operations Chief Edward Gallagher is due to stand trial in a case that has drawn the attention of U.S. President Donald Trump.

Gallagher is charged with murdering a helpless, wounded Islamic State fighter in his custody, and with two counts of attempted murder in the wounding of two unarmed civilians, a schoolgirl and elderly man, shot from a sniper’s perch.

The charges stem from Gallagher’s deployment as a platoon leader to Iraq’s northern city of Mosul, in 2017.

He has pleaded not guilty to those and other charges, including obstructing justice. If convicted, the decorated career combat veteran could face life in prison.

Gallagher says he was wrongly accused and that fellow SEAL team members testifying against him, several under grants of immunity, are disgruntled subordinates who fabricated allegations to force him from command.

His defense team has filed motions seeking either to dismiss the charges altogether, or remove the lead prosecutor from the case, on grounds of alleged misconduct by the prosecutor and agents of the Naval Criminal Investigative Service (NCIS).

The defense specifically has accused Navy lawyers of conducting illegal surveillance of defense attorneys and news media using electronic tracking software secretly embedded in emails sent to the defense.

In court, prosecutors have said the email “auditing tools” they used were designed merely to detect the flow of emails without revealing their content, and were aimed at pinpointing the source of leaks from case files sealed by the judge.

The judge, Navy Captain Aaron Rugh, adjourned the hearing without ruling yet on the defense motions. But Rugh said he had already found the prosecution’s conduct amounted to a violation of the defendant’s Sixth Amendment rights to a fair trial under the U.S. constitution.

Even if the judge refuses to dismiss the case, removing the lead prosecutor, Navy Commander Christopher Czaplak, would probably result in a lengthy delay.

A ruling on the motions could come any time, and momentum seemed to be moving the favor of the defense.

At the end of Thursday’s proceedings, the judge unexpectedly ordered Gallagher released from base confinement at a nearby military hospital center in San Diego while he awaits trial.

He was transferred there from a military brig at a Marine Corps air station in California in March at the direction of Trump, who cited Gallagher’s “past service to our country.”

Trump last Friday said he was considering pardons for a number of service members accused of war crimes, and Gallagher’s case is widely believed to be one of the cases under review.