Willie Stokes, freed from a life sentence after 27 years, was ready to hug his mom and get a corned beef hoagie Tuesday when he walked out of a state prison.

Stokes, 61, of Philadelphia, greeted other family members when freed Tuesday, because his mother was too nervous to come.

"Today is a tremendous day. We're all very thankful," said his lawyer, Michael Diamondstein. "However, it's also a sad day, because it reminds us of how lawless, unfair and unjust Philadelphia law enforcement was for so long."

Stokes was sentenced in a trial influenced by detectives who allegedly offered a key witness sex and drugs at police headquarters in 1983 in exchange for false testimony.

That witness, Franklin Lee, was charged with perjury just days after Stokes was convicted of murder in 1984. However, Stokes didn't learn of this until 2015.

Lee was convicted of perjury, along with rape and murder, serving 35 years in prison. He finished his sentence two years ago and currently works as an assembly line supervisor.

Lee apologized to Stokes in court "for the problem I caused."

"I'm going to take his tears to indicate he's accepting the apology," U.S. Magistrate Judge Carol Sandra Moore Wells said.

Two detectives, now dead, had allegedly offered Lee a deal of sex in exchange for lies to help them close a case on the 1980 murder of Leslie Campbell.

"I fell weak and went along with the offer," Lee told a federal judge in November. In his original testimony at a preliminary hearing for Stokes in May 1984, he claimed Stokes, a neighborhood friend, had allegedly confessed to killing Campbell amid a dice game.

Willie Stokes, Freed, Botched Trial
Willie Stokes smiles after getting out of a state prison in Chester, Pennsylvania., on Tuesday, Jan. 4, 2022, after his 1984 murder conviction was overturned because of perjured witness testimony. Stokes was serving a life sentence and spent decades in prison before learning the witness who testified against him at a 1984 court hearing soon pleaded guilty to perjury over the testimony. Matt Rourke/AP Photo

Lee recanted the story at Stokes' murder trial in August 1984, but Stokes was nonetheless convicted and sent to prison for life. Days later, Philadelphia prosecutors charged Lee with perjury — not over his trial testimony, but over the initial testimony he'd given at the preliminary hearing. Lee pleaded guilty, admitting he'd made up the confession, and was sentenced to a maximum seven-year prison term.

"The homicide prosecutors that used Franklin Lee's testimony to convict Willie Stokes then prosecuted Franklin Lee for lying on Willie Stokes. And they never told Willie Stokes," Diamondstein argued at the November hearing in federal court.

Stokes' mother, now elderly, has been planning for his homecoming as his appeals gained traction, only to face repeated setbacks, she told The Philadelphia Inquirer, which first reported on the case.

But Lee's mother also played a role early on.

In federal court testimony last November, Lee said his girlfriend — who detectives summoned to have sex with him at police headquarters back in 1983 and who was allowed to bring marijuana and a few dozen opioid pills — told his mother about the deal he'd struck.

His mother told the woman not to go down to the station again. Instead, police secured him a sex worker the next time, Lee said.

"Once I talked to my mother, she told me, 'I didn't raise you like that, to lie on a man because you got yourself in a jam,'" Lee testified, according to the transcript. "She said, 'I couldn't care if they give you 1,000 years. Go in there and tell the truth.' And that's what I did."

One surviving prosecutor, now in private practice, did not immediately return messages seeking comment Tuesday. However, he has given a statement saying he doesn't remember either case, according to court files.

Philadelphia police offered no immediate comment on the case.

The U.S. magistrate who heard the appeal called the omission an "egregious violation of (Stokes') constitutional rights," and a U.S. district judge agreed, overturning the conviction last week.

Philadelphia District Attorney Larry Krasner, whose office has championed about two dozen exoneration cases, supports Stokes but has not yet formally decided whether to retry him. That decision should come before a scheduled Jan. 26 hearing in state court, a spokesperson said.

The Associated Press contributed to this report.