A Southern California mass killer will be spared the death penalty amid a long-running scandal over local authorities' use of jailhouse informants, a judge decided Friday.

Judge Thomas M. Goethals said Scott Dekraai would not be sentenced to death after pleading guilty to killing eight people in a 2011 shooting rampage at an Orange County hair salon.

The ruling leaves only the possibility that Dekraai, 47, will be sentenced to life in prison.

It's rare for a judge to bar prosecutors from seeking a death sentence. While acknowledging the "horrendous" nature of Dekraai's crime, Goethals found that failures by the prosecution team would prevent a fair penalty phase of the trial.

Dekraai's defense attorneys had argued that repeated failures by sheriff's authorities to reveal records related to informants in the county jail show the agency can't be trusted to turn over evidence that could favor their client.

Goethals noted authorities repeatedly flouted his orders to produce the documents.

"To accept chronic non-compliance with such orders in any case, much less a case of this magnitude, would dangerously undermine the integrity of, and ultimately the community's respect for, the justice system," the judge wrote.

"If this case had been prosecuted from the outset by the Orange County district attorney within the most fundamental parameters of prosecutorial propriety, this defendant would likely today be living alongside other convicted killers on California's death row in San Quentin State Prison."

Some relatives of victims had grown weary of the drawn-out process for determining whether Dekraai would face the death penalty and were pleased by the ruling.

"Even if he was executed, it would have been a drug-induced easy out," Bethany Webb, whose sister was killed, told the Los Angeles Times outside court.

Webb said she hoped the ruling would result in Dekraai fading "quietly into the hell he deserves."

The California attorney general's office had argued there was no indication authorities have evidence that would assist Dekraai in the limited scope of a penalty phase hearing. It also said the former tugboat operator can get fair treatment.

The Sheriff's Department and district attorney's office issued statements saying the facts of the case supported a death penalty verdict.

"Notwithstanding the issues that were raised by the court's ruling, we believe the defendant would have received a fair trial during the penalty phase of the criminal proceedings," the department said. "The decision to remove the death penalty rests at the feet of Judge Goethals and nobody else."

Robert Dunham, executive director of the Death Penalty Information Center in Washington, said cases where prosecutors are barred from pursuing capital punishment are unusual.

"This case is notable and is being watched because of the severity of the offense, but it is also notable and being watched because of the unparalleled nature of the government misconduct," he said.

The ruling came during an uproar over the use of jailhouse informants in the Southern California county. The U.S. Department of Justice and state attorney general's office are each investigating the county's practices, and prosecutors have seen at least four murder cases upended by the scandal.

Dekraai pleaded guilty to killing his hairstylist ex-wife Michelle Fournier before turning his gun on her co-workers and others at the salon where she worked in Seal Beach. He was arrested minutes after the rampage that left eight dead and one wounded.

Dekraai's lawyer Scott Sanders began asking questions about the use of jailhouse informants after noticing the same snitch had chatted up Dekraai and another one of his clients.

Authorities can use informants but can't have them deliberately elicit information from defendants once they are represented by lawyers.

After finding sheriff's authorities lied or withheld informant-related information, Goethals yanked the district attorney's office off Dekraai's case in 2015. He also ordered authorities to release jailhouse records. Documents have been released bit by bit.

"The concealment has gone on forever," Sanders said during closing arguments last week. "When people don't tell the truth, we really have no sense of where it stops."

Deputy Attorney General Michael T. Murphy said misconduct may have occurred in the case but Dekraai needs to be punished for his crimes. He said the government holds no documents that will prove relevant to penalty hearings focused on the killings and Dekraai's comments immediately after his arrest.

"The defense has failed to show that any actions of the government in the past have eliminated the possibility of getting a fair penalty trial," Murphy told the court.