PHILADELPHIA -- The Pennsylvania Supreme Court on Wednesday upheld a stay of execution for Terry Williams, a death row inmate who killed two men he said sexually abused him in his teens.

Williams had been scheduled to die Wednesday night by lethal injection at the state's death chamber in rural Centre County, but a state judge tossed out his death sentence last week after finding that prosecutors mishandled evidence in the case. His death warrant, signed by Gov. Tom Corbett, expires at midnight. The execution would have been the first in the state in more than 50 years of a prisoner who had not abandoned his appeals.

An appeal to reinstate Williams' death sentence remains before the state Supreme Court, however, and if the court finds for the prosecution, Williams would again be on track to be executed. "This is not over, not even close," said Victor Abreu, an attorney for Williams.

Seth Williams, the Philadelphia district attorney, said he continues to believe that Williams deserves death. "The Supreme Court will have the time to look at all the facts," he said in a statement.

On Friday, a state judge vacated the death sentence after ruling that prosecutors withheld key evidence from defense attorneys before Williams' trial nearly 30 years ago for killing Amos Norwood, a 56-year-old Philadelphia chemist. Williams was 18 at the time of the murder.

Norwood was found beaten and stabbed to death in a Philadelphia cemetery in 1984. At trial, prosecutors said the motive for the crime was robbery and told jurors that Williams committed the murder "for no other reason but that a kind man gave him a ride home." Jurors sentenced Williams to death after an hour of deliberation.

Several months before being tried for killing Norwood, Williams was found guilty of killing a 51-year-old man who had paid him for sex when Williams was 17. The jury in that case rejected a death sentence after it heard evidence alleging that the victim sexually abused Williams and other teen boys. The same prosecutor, Andrea Foulkes, handled both cases.

In last week's ruling, Judge M. Teresa Saramina of the Pennsylvania Court of Common Pleas halted the execution of Williams after determining that his death sentence was flawed because Foulkes withheld crucial evidence from the defense before his trial for killing Norwood.

Saramina said she based her order on previously undisclosed evidence from police and prosecution files revealed at a hearing in September that indicated Norwood preyed sexually on teen boys and had paid Williams for sex.

From the bench, Saramina said Foulkes "played fast and loose" with the facts before and during the trial, and that key witness statements were "sanitized" before being turned over to the defense.

Foulkes, an assistant Philadelphia district attorney at the time of the trial, denied any misconduct.

The prosecution's attempt to put Williams to death may still hinge on a decision by Foulkes' boss at the time of the trial, Ronald D. Castille, who now serves as the chief justice of the Pennsylvania Supreme Court.

Earlier this week, Castille denied without comment a defense motion requesting that he recuse himself from hearing the Williams appeal due to the appearance of a conflict of interest. Castille authorized prosecutors to seek the death penalty against Williams, and supervised Foulkes during her prosecution.