In a stunning ruling, a Cook County judge on Thursday said a Chicago man was “innocent” of a double murder for which he served time in prison for but denied him a “certificate of innocence” and a shot at compensation from the state by finding that he was to blame in part for his conviction.

Judge Thomas Byrne said Alstory Simon played a “role” when he pleaded guilty in the double murder case that resulted in another man convicted of the murders being freed and eventually brought an end to the death penalty in Illinois.

Byrne outlined his reasoning in a 15-page ruling that maintained that Simon was a willful participant in the plan to clear Anthony Porter of the 1982 murders of Jerry Hillard and Marilyn Green.

Porter was just hours from being executed, and his release pushed former Gov. George Ryan to declare a moratorium on the death penalty.

“Simon’s willingness to go along with the story even after his conviction is telling,” the judge wrote, skewering Simon and then-Northwestern University journalism professor David Protess for creating “fiction.”

Simon, now 65, has since said he was forced into confessing by Protess and Paul Ciolino, a private investigator who was working with Protess in the investigation leading to Porter’s release.

Simon said Ciolino promised him free legal representation and ensured him he would get a short prison sentence. Simon also claims Ciolino told him Porter would pay him money he would receive from a legal settlement and that he would make millions from book and movie deals about the case.

Simon believed he he would be compensated for his compliance, the judge said. He “played an important role in Protess’ plan to abolish the death penalty in Illinois,” Bryne wrote in his decision. “Without Simon the allegation of Porter’s innocence was unpersuasive, and the circumstances surrounding Porter’s release would not have been as dramatic or garnered the amount of attention that they ultimately did. Simon’s willing participation was crucial. By playing his role, Simon assisted Protess in influencing the public perception and manipulating the criminal justice system, resulting in the release of a convicted murderer.”

Simon just furthered the “fiction that Protess was feeding to the public through the media,” the judge said.

“Simon acted out his role and gave a convincing performance,” Bryne wrote.

Simon also was motivated to plead guilty to the double murders in 1999 to avoid charges in a homicide case in Milwaukee, Byrne said.

“By pleading guilty, Simon received a tangible benefit by avoiding potential prosecution in Wisconsin,” the judge wrote.

Even though some still say Porter was the killer, State’s Attorney Anita Alvarez launched a reinvestigation of the case in 2013 and concluded a year later that Protess and his students used “alarming tactics” that led to Simon’s plea.

Simon was released from prison after prosecutors dropped charges in the murders in late October 2014.

Simon has since filed a federal lawsuit against Northwestern University, Protess, Jack Rimland, who was Simon’s defense attorney in 1999, and Ciolino.

Arthur Lurigio, a psychology and criminal justice professor at Loyola University Chicago, said the judge made a “reasonable and fair decision” and couldn’t have ruled any other way.

Simon, who made a tearful apology to the victims’ families, did not meet the four-pronged legal standards needed to receive a certificate of innocence, Lurigio said.

“It’s very clear to me that Simon’s own voluntary conduct led to his conviction. That’s crystal clear,” Lurigio said.

Simon’s attorney, Terry Ekl, said he would appeal the ruling.

“Over the past 12 years, I have been representing Mr. Simon we have had a series of setbacks prior to securing his freedom. This is another setback and I am confident that the judge’s ruling will be overturned on appeal,” Ekl said in an email to the Chicago Sun-Times.

“Although we agreed with the judge’s conclusion that the evidence is clear that Simon was innocent of the charges and that he had been framed by Protess and Ciolino, we disagree that Simon brought about his own conviction by pleading guilty,” Ekl added.