A Cook County judge Wednesday ruled that retired Chicago Police detective Reynaldo Guevara lied on the witness stand last month when the 74-year-old testified he didn’t beat confessions out of two men now serving life sentences for murder.

Judge James Obbish threw out confessions from Gabriel Solache and Arturo DeLeon-Reyes, giving a thorough dressing down to prosecutors and condemning Guevara for giving “bald-faced lies” when questioned under oath in October about his interrogations of the two men.

Guevara, who had been granted immunity in an unprecedented move by prosecutors, responded to all but a handful of questions that he didn’t remember the 1998 investigation, and offered only meek denials of abuse when pressed to give a yes-or-no answer.

Guevara had denied the abuse allegations under oath ahead of Solache and DeLeon-Reyes’ 2000 trial, but Obbish said he could no longer credit those statements as truthful.

“Guevara said he didn’t remember,” Obbish said. “That’s a bold-faced lie. I can’t give an ounce of credibility to something he did 20 years ago. If he would lie after being given immunity under oath, why would this court . . . believe that he was telling the truth when he first testified?”

The ruling throws into disarray prosecutors’ attempt to preserve the convictions, Obbish noted, pointing out that the two men’s confessions were made to Guevara, and Guevara clearly won’t provide credible testimony if the men are granted a new trial.

Defense lawyers entered a motion to vacate their convictions immediately after Obbish made his ruling to suppress their confessions.

Prosecutors had only taken the rare step of offering the retired police officer immunity because Guevara has refused to testify under oath about allegations of abuse made in wrongful conviction cases brought by dozens of defendants.

Guevara had denied beating suspects or coercing witnesses when DeLeon-Reyes and Solache made abuse claims during their trials, but in recent years, Guevara has clammed up in the face of questioning in civil depositions and post-conviction cases.

Guevara’s lawyers in the past have said the allegations — and a number of witnesses who have recanted their testimony from Guevara’s old cases — are the result of a conspiracy by gang members to get revenge on the decorated detective.

After Guevara’s testimony earlier this year, prosecutors asked the judge to consider a transcript from a 2000 hearing where the detective denied beating Solache and DeLeon-Reyes.

Eric Sussman, a top deputy to State’s Attorney Kim Foxx, has said prosecutors put Guevara on the stand in hope of preserving a legitimate conviction.