Corey Williams was ordered released from a Louisiana prison Monday after serving more than 20 years for a murder many believe he did not commit. His sudden freedom—he is expected to be released early Tuesday—is a surprising twist in a legal drama that began with an ill-fated pizza delivery at a house in Shreveport in January 1998 and ended with the intellectually disabled man’s case pending before the U.S. Supreme Court.

Williams’ lawyers reached a deal with Caddo Parish attorneys in the past week or so—before the justices in Washington announced whether they would accept his case for review. After years of professing his innocence he agreed to plead guilty to manslaughter and obstruction of justice charges, which allowed prosecutors a face-saving way to credit him with time served and then endorse his immediate release.

The deal was approved Monday by Caddo Parish District Judge Katherine Dorroh, who then vacated Williams’ first-degree murder conviction. Her involvement, too, is ironic. She had ruled against Williams once before in the case and perhaps is best known as the trial judge who denied compensation for Glenn Ford, another man who spent decades in a Louisiana prison for a wrongful conviction before dying shortly after his release.

I’ve been following Williams’s cause since 2015. Last month, The Marshall Project chronicled anew the dubious case against him in our Case in Point series. It’s a case that got worse over time. Williams, 16 years old when arrested, was convicted of murdering a pizza delivery man and then sentenced to death even though all of the physical evidence in the case pointed to different and more compelling suspects. Police interrogated the teenager through a long night, and gained a “confession” from him, even though they knew about his profound intellectual disability.

The prosecutor in his case was Hugo Holland, known for his zeal in capital cases involving black defendants. One of the reasons state attorneys endorsed a plea deal now might be because Williams’ lawyers recently discovered (in addition to all of the other flaws in the case) that trial prosecutors had faked “summaries” of witness statements to incriminate Williams and draw attention away from other suspects.

A Supreme Court decision focusing on those summaries and the way prosecutors manipulated them might have more than embarrassing for Caddo Parish prosecutors. It also might have jeopardized other cases where similar summaries were used. State attorneys never responded to the petition Williams’ lawyers filed for a review of the case by the Supreme Court and now the justices will have no reason to hear the case or decide its merits.

But the deal is harsh for Williams, too. By pleading guilty, by not waiting for the Supreme Court perhaps to rescue him, he forgoes the chance to seek compensation from the state and will have a conviction on his record as he begins—at the relatively young age of 36—to chart a post-prison life for himself. His lawyers may have felt that getting Williams quickly out of prison, where he reportedly has been bullied because of his disabilities, was more important than ensuring he might one day seek compensation from a state unlikely to grant it.