LOS ANGELES (Reuters) - A California man convicted of the worst mass killing in Orange County history was spared the death penalty on Friday after a judge found that serious misconduct by prosecutors had violated his rights to a fair trial.

FILE PHOTO: Scott Dekraai (R) pleads guilty of killing eight people in October 2011, at Orange County Superior Court in Santa Ana, California, U.S., May 2, 2014. REUTERS/Alex Gallardo/File Photo

The ruling means that, barring a successful appeal, former tugboat worker Scott Dekraai, 47, will be sentenced to life in prison for killing eight people in a 2011 shooting rampage at a Seal Beach hair salon.

“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 be living alongside other convicted killers on California’s Death Row,” Superior Court Judge Thomas Goethals wrote in a 19-page ruling.

Dekraai pleaded guilty to eight counts of first-degree murder in May 2014, making him eligible for the death penalty, but the judge took the case away from Orange County prosecutors the following year over accusations that a jailhouse informant was improperly used to wring a confession from him.

The California Attorney General’s Office has handled the prosecution since then but the case has been stalled over litigation due to a widening scandal regarding the use of informants in the Orange County jail.

Orange County District Attorney Tony Rackauckas said in a written statement that he was disappointed in the ruling.

“Whether some members of the Orange County Sheriff’s Department failed to produce tangential information in a timely manner has nothing to do with what Dekraai did and the fact that Dekraai deserves the death penalty,” Rackauckas said.

“Scott Dekraai executed and confessed to the deadliest shooting in the history of Orange County, long before he was booked into the Orange County Jail,” the Orange County Sheriff Department said in a separate statement.

California’s Deputy Attorney General Michael Murphy told reporters outside court that his office had not yet decided whether to appeal. Dekraai’s attorney could not be reached for comment.

Dekraai was locked in a custody battle with his ex-wife Michelle Fournier when he walked into Salon Meritage carrying three guns and opened fire.

Fournier was killed in the shop along with six others. Outside, Dekraai fatally shot 64-year-old David Caouette, who was sitting in his sport utility vehicle.

Dekraai was arrested blocks from the bloody scene in the heart of Seal Beach, a community southeast of Los Angeles known by locals as “Mayberry by the Sea” for its bucolic, small-town ambiance.