A Philadelphia man was freed from prison Tuesday after 37 years in a case marred by detectives who allegedly offered a witness sex and drugs at police headquarters in 1983 in exchange for false testimony. 

The trial witness was charged with perjury just days after Willie Stokes was convicted of murder in 1984. But Stokes didn't learn about that perjury plea until 2015, decades into a life sentence. 

Stokes, 61, walked out of a state prison near Philadelphia eager to get a hug from his mother and a corned beef hoagie. His mother was too nervous to come after several earlier disappointments, so he greeted other family members instead. 

BEVERLY HILLS GUNS SEES BOOM IN BUSINESS AFTER FOLLOW-HOME MURDER 

Willie Stokes, center, and lawyer Michael Diamondstein walk in Chester, Pennsylvania, on Tuesday, Jan. 4, 2022, after Stokes' 1984 murder conviction was overturned because of perjured witness testimony.

Willie Stokes, center, and lawyer Michael Diamondstein walk in Chester, Pennsylvania, on Tuesday, Jan. 4, 2022, after Stokes' 1984 murder conviction was overturned because of perjured witness testimony. (AP Photo/Matt Rourke)

"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." 

Both detectives who allegedly offered witness Franklin Lee a sex-for-lies deal to help them close a 1980 murder case are now deceased. Lee was in custody on unrelated rape and murder charges at the time, and said he was also promised a light sentence. 

"I fell weak and went along with the offer," Lee told a federal judge in November, recalling his testimony at a May 1984 preliminary hearing when he claimed Stokes, a neighborhood friend, had confessed to killing a man named Leslie Campbell during a dice game. 

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. 

Willie Stokes, center, walks from a state prison in Chester, Pennsylvania, on Tuesday, Jan. 4, 2022, after his 1984 murder conviction was overturned because of perjured witness testimony.

Willie Stokes, center, walks from a state prison in Chester, Pennsylvania, on Tuesday, Jan. 4, 2022, after his 1984 murder conviction was overturned because of perjured witness testimony.  (AP Photo/Matt Rourke)

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. 

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.

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.  (AP Photo/Matt Rourke)

As for Lee, he ended up serving 35 years on the rape, murder and perjury charges. He got out of prison two years ago and now works as an assembly line supervisor. 

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

CLICK HERE TO GET THE FOX NEWS APP 

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

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.