A Cook County judge on Thursday ordered a new trial for Jackie Wilson, ruling that the confession he made in the murder of two police officers nearly 40 years ago was the result of torture by the underlings of disgraced former Chicago police Cmdr. Jon Burge.

The ruling opens yet another chapter in the decadeslong Burge saga that began with allegations of abuse by Wilson and his brother, Andrew, at the hands of Area 2 detectives during the 1982 investigation of the murders of CPD officers William Fahey and Richard O’Brien.

Riffing on the Black Lives Matter and Blue Lives Matter T-shirts he has seen in his courtroom during the hearings, Judge William Hooks said that evidence showed that Jackie Wilson –– whether he is guilty or not –– had his rights violated.

“All rights matter. The rights of the good, and the bad and the ugly, all count. Who is good, who is bad and who is ugly is not the job of this court,” Hooks said near the end of a four-hour reading of his entire 119-page order.

Seated beside his attorney of some 35 years, G. Flint Taylor, Jackie Wilson nodded and smiled as Hooks announced he was overturning his conviction and ordering a new trial. Seated in the front row of the courtroom gallery, relatives of Fahey and O’Brien seemed unsurprised.

Hooks’ ruling recited evidence from hearings that have spanned months, citing as well rulings in the many civil rights cases filed by defendants who claimed to have been tortured by Burge and his men.

Attempts to refute Wilson’s tearful testimony during the hearing were less convincing, Hooks said, largely because Burge and others accused of meting out the abuse, as well as a prosecutor who took Wilson’s statement, all refused to answer questions under oath.

RELATED: Alleged torture of Jackie Wilson doesn’t diminish his guilt in cops’ murders

Wilson’s case is likely far from over. Special Prosecutor Michael O’Rourke, a private attorney hired to handle the case against Wilson, said he would appeal Hooks’ ruling. Even without a confession to use as evidence, O’Rourke has said he would take Wilson to trial again, which would mark the third time Wilson has stood trial for the double-murder.

Andrew Wilson died in prison in 2007, having been tried and convicted twice — the second guilty verdict coming even after his confession was tossed out.

Andrew Wilson’s case was the first to be overturned based on allegations of torture by Burge’s detectives at Area 2. Wilson won a $1 million civil judgment from the city, and his case would eventually lead to Burge’s firing, and in ensuing decades, the payouts of more than $100 million to defendants who claimed they were victims, the creation of a state commission on torture and a landmark legal settlement between the city and victims that required Chicago Public Schools to teach a history of the scandal.

Burge was convicted of perjury in 2010 for denying the abuse, and served 4 ½ years in prison.

Earlier this year, Jackie Wilson had tearfully testified that he was threatened and beaten by police during his trip to Area 2, and the abuse grew worse once he was hauled into an interrogation room. There, he said, detectives struck with a phone book, kicked him in the groin, electrocuted him with an electrical device and forced a gun into his mouth.

The claims matched those of his brother. Jackie Wilson’s attorneys brought forth a “mountain of evidence” in the form mostly of similar stories of abuse from other suspects who passed through Area 2 in the days after the Fahey and O’Brien killings.

Burge appeared in court only on video, fielding questions during a 2016 deposition by his longtime nemesis, G. Flint Taylor.

When questioned about the Wilsons or other accusations of abuse, a smoldering Burge asserted his Fifth Amendment rights, and occasionally offered a general statement of contempt for Taylor.

Hooks’ ruling comes after the state Torture Inquiry and Relief Commission granted a review of Wilson’s torture claims, which had been discounted by other judges at Wilson’s first and second trials.

Conspicuously absent from Thursday’s hearing was the massive contingent of police officers who had overflowed the courtroom gallery for the first hearing on Wilson’s bid to have his confession tossed.

Standing with O’Brien and Fahey’s families after the hearing, Fraternal Order of Police Vice President Martin Preib gave a brief statement to reporters, denouncing the judge’s ruling and what he called the “innocence industry.”

Fahey and O’Brien’s relatives declined to speak with the press after the hearing. In an op-ed published in Thursday’s Chicago Sun-Times, Fahey’s daughter wrote that her family did not want to endure the “pain and anguish” of a third trial, and believed Jackie Wilson was guilty.

“I understand that cases where the validity of confessions is in doubt deserve fair scrutiny,” she wrote. “But in this case, there is ample evidence beyond an allegedly coerced confession to support the two prior guilty verdicts.”

Wilson will remain jailed without bond, but his attorneys said they intend to request bond for the 57-year-old at a hearing next week.