Navy SEAL Edward Gallagher’s defence team have filed motions to remove lead prosecutor from the case for misconduct.

The military judge presiding over the court martial of a US Navy SEAL charged with war crimes said on Friday prosecutors who electronically tracked email communications of defence 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 United States President Donald Trump.

Gallagher is charged with murdering a helpless, wounded Islamic State of Iraq and the Levant (ISIL or ISIS) 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 defence 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).

Defence attorney Timothy Parlatore, representing Gallagher, spoke with reporters at a pre-trial hearing in San Diego [Earnie Grafton/Reuters]

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

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 defence 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 US 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 at any time, and momentum seemed to be moving in favour of the defence.

At the end of Thursday’s proceedings, the judge unexpectedly ordered Gallagher be released from base confinement at a nearby military hospital centre 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.