A military judge on Friday refused to dismiss the murder case of a decorated Navy SEAL, but found the prosecution's meddling in defense lawyer emails troubling enough to reduce the maximum penalty he faces.

The judge rebuked prosecutors by reducing the maximum possible penalty in the case from life in prison without parole, to life with the possibility of parole.

Capt. Aaron Rugh said an effort to track emails sent to lawyers for Special Operations Chief Edward Gallagher violated constitutional rights against illegal searches and the right to counsel by interfering with attorney-client privilege.

'It hampered the defense's opportunity to prepare for trial as they became necessarily enmeshed in discovery and litigation related to the operation, thereby harming the accused's right to competent counsel,' Rugh said.

The action also harmed the public's view of the military justice system and cast doubt on Gallagher's ability to give a fair trial, Rugh said.

Special Operations Chief Edward Gallagher was freed from base confinement in San Diego on Thursday last week, less than two weeks before he is due to go on trial. He is pictured with his wife Andrea after leaving the courtroom

The ruling was the latest rebuke in one of the Navy's most prominent war crimes cases and came just days after the judge removed the lead prosecutor as the defense sought dismissal of the case for alleged misconduct in what they characterized as 'spying.'

Rugh found the intrusion 'placed an intolerable strain on the public's perception of the military justice system.'

'Applying its broad discretion in crafting a remedy to remove the taint of unlawful command influence,' Rugh said he would remove the maximum penalty of life imprisonment without parole if Gallagher is convicted of premeditated murder.

Gallagher could now face life in prison with a chance of parole.

To relieve the 'strain of pretrial publicity,' Rugh also said he would allow the defense to reject two more potential jurors without cause during jury selection.

Gallagher is scheduled to go to trial June 17 on murder and attempted murder charges.

Gallagher (left and right) is scheduled to go to trial June 17 on murder and attempted murder charges. He is charged with killing an injured teenage militant in Iraq

Navy spokesman Brian O'Rourke said the Navy vows to give Gallagher a fair trial.

On Monday, Rugh removed the lead prosecutor, Cmdr. Christopher Czaplak. He said it was not within his power to determine whether Czaplak engaged in misconduct, but the potential for a probe into his actions could present a conflict and required his removal.

It is extremely unusual for a military judge to remove a prosecutor only days before the start of a trial. Gallagher had been facing trial on Monday until Rugh delayed it for another week.

Last week, Rugh unexpectedly released Gallagher from custody as a remedy for interference by prosecutors in the middle of a hearing on several defense motions.

Rugh rejected allegations that prosecutors withheld evidence that could help his defense.

The military justice system has won few war crime convictions and been criticized for being ineffective.

Gallagher has pleaded not guilty to murder in the death of an injured ISIS militant in Iraq in 2017 and attempted murder for allegedly picking off civilians from a sniper's perch

Republicans in Congress have lobbied for Gallagher, saying he has been mistreated. President Donald Trump intervened to move Gallagher to less restrictive confinement in March and has considered dismissing the charges.

Gallagher pleaded not guilty to a murder charge in the death of an injured teenage militant in Iraq in 2017 and to attempted murder in the shooting of two civilians from a sniper's perch.

He blames disgruntled platoon mates for fabricating complaints about him because they didn't like his tough leadership.

Defense lawyers for Gallagher and his commanding officer, Lt. Jacob Portier, have said most of the court documents leaked to reporters have hurt their clients, so the sources are likely on the government side. But Rugh found no evidence of that.

Portier has denied charges of conduct unbecoming an officer after being accused of conducting Gallagher's re-enlistment ceremony next to the militant's corpse.

Navy Special Operations Chief Edward Gallagher leaves a military courtroom on Naval Base San Diego with his wife, Andrea Gallagher, Friday, May 31

Rugh indicated he was misled about the effort to embed code in emails sent to the defense team and a journalist to track where those messages were sent to find the source of leaks that have plagued the case.

He said he didn't have the authority to approve such a tactic and was led to believe Czaplak was working with federal prosecutors so his consent was not necessary.

Rugh said he learned Friday that the U.S. attorney's office in San Diego had not approved or coordinated the tracking, defense lawyer Tim Parlatore said.

Evidence at hearings last week showed an intelligence specialist from Naval Criminal Investigative Service conducted criminal background checks on three civilian lawyers and a Navy Times journalist who has broken several stories based on documents that are only to be shared among lawyers in the case.

Parlatore, who was among the lawyers investigated, accused prosecutors of a 'rogue, relentless, and unlawful cyber campaign' that may have violated attorney-client privilege and hurt his client's ability to get a fair trial.

Czaplak downplayed the move, saying the code embedded in emails recorded nothing more than what marketers use to find out where and when messages were opened by recipients.

The government said the investigation did not find the source of leaks.