View more videos at: http://nbcphiladelphia.com.

A Philadelphia judge halted next week's scheduled execution of a teenage killer after finding the trial prosecutor suppressed evidence the victim was molesting boys, “sanitized” witness statements before giving them to the defense and lied about a secret deal she'd struck with the accomplice.

The judge also tossed out Terrance “Terry” Williams' death sentence, granting him a new sentencing hearing.

Williams has been on death row for 28 years and was set to be executed Wednesday. He would have been the first person executed in Pennsylvania in 50 years who had not given up his appeals.

Williams, now 46, could still face the death chamber if prosecutors successfully appeal Friday's ruling. Philadelphia District Attorney Seth Williams, who planned an afternoon news conference, has called the defendant a “brutal two-time murderer.”

Common Pleas Judge M. Teresa Sarmina accused trial prosecutor Andrea Gelman Foulkes of “gamesmanship” in order to win the 1986 death-penalty case.

“She did at times play games and take unfair measures to win,” Sarmina said Friday, reading aloud her lengthy ruling. “She wanted to win.”

Williams was not in court, but his aunt, daughter and other supporters broke into applause.

The judge deemed Foulkes' testimony last week about her work in the case not credible. Foulkes, through a spokeswoman at the U.S. attorney's office in Philadelphia, where she now works, declined immediate comment.

Given new evidence unearthed only this past week from police homicide files and Foulkes' own notes, Sarmina said the jury might not have voted for the death penalty if they knew more about victim Amos Norwood.

Foulkes herself testified last week that she suspected there was a sexual link between the 56-year-old Norwood and 18-year-old Williams, but neither she nor police pursued it much. Statements from Norwood's wife and pastor about prior fondling complaints and odd interactions with teenage boys never reached the defense lawyer or jurors.

Related: Penn. board rejects clemency in murder case, execution still planned

Related: Widow asks Pennsylvania governor not to execute husband's killer

AP Terrance Williams is shown in this undated Pennsylvania Department of Corrections' photo.

Williams now says he had been abused since he was 13 by Norwood, a chemist and church deacon who spent long hours working with underprivileged boys through a church theater program.

Williams, a star high school quarterback from a troubled family, was secretly having sex with older men in exchange for money, clothes and gifts. He had killed 50-year-old Herb Hamilton five months earlier, when he was 17, in a gruesome, clearly sexual slaying. Foulkes herself had prosecuted Williams in that case, which detailed the sex motive and resulted in a third-degree murder conviction.

Three new affidavits this year from Norwood accomplice Marc Draper, a childhood friend, led to what the judge called the “extraordinary” late-stage evidence hearing this past week.

Draper had refused to talk to Williams' appellate lawyers for years. But angry over the raw deal he feels he made with Foulkes, and made aware of Williams' execution date, he opened up this year and recanted his trial testimony. He said he'd told Foulkes and detectives about Williams' sexual relationship with Norwood. They didn't want to hear it, he said.

Sarmina ordered prosecutors to bring the original police files to court. Interview notes made by Foulkes and by police corroborated his story.

Draper said he'd been promised a chance for parole after 10 or 15 years if he testified that he and Williams fatally beat Norwood during a robbery.

Instead, he got a life sentence — which in Pennsylvania, means life without parole. Draper said he didn't understand that. Foulkes stated at trial that she had no side deals with Draper, her star witness. Yet she later wrote a letter for Draper — sent to his father, a policeman — promising to tell the parole board about his cooperation if Draper was ever up for parole. Unbeknownst to Draper, that could only happen if his sentence was changed on appeal.

Federal courts had previously found the work of Williams' now-disbarred trial lawyer “unconstitutionally deficient,” although they refused to throw out the death sentence.

Federal public defenders from a death-penalty unit have represented Williams since 1996. They say the errors found in his case are far too common.

“That we were talking about executing somebody who meets his lawyer a day before trial is an indictment of the system. The fact we're talking about this new evidence a week before execution is a bigger indictment of the system,” public defender Victor Abreu said Friday.

Williams had been scheduled to be executed by lethal injection. He would have become the first Pennsylvania inmate executed since 1962 who had not given up his appeals.

“He's hanging in there. It's not an easy situation. His execution is five days away,” said Shawn Nolan, another public defender.

Williams also has a clemency petition pending with the state Board of Pardons, which reopened his case Thursday but did not issue a ruling. The board could be asked to revisit the petition if prosecutors successfully appeal Sarmina's ruling to the state Supreme Court.

Nolan also released the following statement regarding the judge's decision:

On behalf of Terry Williams, we are extremely pleased that Judge Sarmina, after carefully considering all of the evidence in this case, has vacated the death sentence based on misconduct by the prosecution. Her decision was right and well-reasoned. As prosecutor for more than 10 years and a judge who likely presided over more than a hundred homicide trials, Judge Sarmina certainly understands how the prosecution misled the jury in this case. The Philadelphia District Attorney should stop their appeals and stop fighting to have Terry executed. The District Attorney’s very own files were replete with evidence from as early as 1984 of predatory, exploitive and abusive acts by Herbert Hamilton and Amos Norwood against Terry Williams and other teenage boys. It is legally and ethically unconscionable that Seth Williams and his Assistants have been advocating for the execution of Terry Williams after hiding critical evidence from jurors and continuing to hide it for 28 years. Judge Sarmina found that the trial prosecutor engaged in misconduct. She found that the prosecutor 'played games and took unfair measures to win.' She also noted that the prosecutor violated her ethical duty for failing to turn over evidence in the files in the possession of the Commonwealth. If the DA appeals, we are confident that the Pennsylvania Supreme Court will not overturn Judge Sarmina’s well-reasoned decision, and do not believe that the Court will tolerate the prosecutor’s actions in this case, especially when life or death are at issue. We are also hopeful that Governor Tom Corbett and the Pennsylvania Board of Pardons will now grant clemency in light of Judge Sarmina’s decision and the significance of the evidence that prosecutors kept from the Board during their life or death deliberations. A majority of the Board, including Attorney General Linda Kelly, previously voted in favor of clemency. Surely, after considering the new evidence, they will not allow this execution to go forward.

More content from NBCNews.com:

Follow US News from NBCNews.com on Twitter and Facebook



