BOSTON — The highest court in Massachusetts on Friday granted a new trial to a man convicted in the 1993 killing of a Boston police officer, finding that jurors likely would have had “diminished confidence” in the thoroughness of the police investigation had they known about corruption among the victim and detectives who investigated his killing.

The ruling by the Supreme Judicial Court affirms an earlier decision by a Superior Court judge who found that Sean Ellis did not receive a fair trial in the fatal shooting of Detective John Mulligan.

Mulligan was shot five times in the face as he slept in his car while on a private security detail outside a pharmacy. Ellis was one of two men convicted of killing Mulligan to steal his gun. He spent 22 years in prison after being convicted of first-degree murder, but was freed on bail last year after Judge Carol Ball’s ruling.

In its decision, the Supreme Judicial Court found that new evidence uncovered by Ellis’ attorney, Rosemary Scapicchio, showed that two detectives who investigated Mulligan’s slaying “had been engaged with the victim in criminal acts of police misconduct as recently as seventeen days before the victim’s murder.”

“With the victim’s complicity, these detectives would likely fear that a prolonged and comprehensive investigation of the victim’s murder would uncover leads that might reveal their own criminal corruption,” Chief Justice Ralph Gants wrote in a unanimous opinion.

“They, therefore, had a powerful incentive to prevent a prolonged or comprehensive investigation, and to discourage or thwart any investigation of leads that might reveal the victim’s corrupt acts.”

Ball wrote in her ruling that the jury should have been told Mulligan and the detectives investigating Mulligan’s killing were among a group of police officers who had robbed drug dealers.

The high court also agreed with Ball’s finding that police and prosecutors didn’t give Ellis’ trial lawyers all the evidence they were entitled to, including federal and police reports suggesting others had motives to kill Mulligan.

Scapicchio said Ellis “broke down in tears of relief and joy” when she told him about the court’s decision upholding Ball’s order for a new trial. She called for an independent investigation of Ellis’ case.

“Why isn’t there an investigation somewhere as to how a 19-year-old black kid could be put away for 22 years and evidence that could have exonerated him was hidden by the police department? Don’t we want to know how that happened to make sure it doesn’t happen in other cases?” she said.

A spokesman for the Boston Police Department declined to comment immediately.

Jake Wark, a spokesman for Suffolk District Attorney Daniel Conley, said prosecutors “fully intend to retry Mr. Ellis on a first-degree murder indictment.”

After Ball’s ruling, Wark said nothing in her ruling that contradicts evidence that led to Ellis’ conviction, including witnesses who said they saw Ellis crouching near Mulligan’s car and then speeding away in another car.

Ellis’ co-defendant, Terry Patterson, was convicted during a separate trial, but his conviction was later overturned. He later pleaded guilty to manslaughter and was released from prison in 2007.