A Philadelphia man who was serving a life sentence for murder was released from prison Friday after the District Attorney’s Office said he didn’t get a fair trial.

Eric Riddick, 51, had served more than 29 years behind bars in the 1991 shooting death of William Catlett in Southwest Philadelphia. He and others have said he is innocent and was not at the shooting scene.

Under an agreement with the District Attorney’s Office, Riddick’s first-degree murder conviction was vacated Friday, and he pleaded no contest to third-degree murder and was resentenced to 11 to 22 years in prison, time he has already served. That set the stage for his release.

Patricia Cummings, the supervisor of the District Attorney’s Conviction Integrity Unit, told Common Pleas Court Judge Lucretia Clemons that Riddick was deprived of his right to a fair trial because of evidence that was not fully disclosed to his then-defense attorney. However, she said that while prosecutors do not believe Riddick killed Catlett, there is credible evidence he was an accomplice to the crime.

Riddick and Catlett were members of rival drug gangs arguing over territory, prosecutors say, and on the evening of Nov. 6, 1991, Catlett was fatally shot at 58th and Belmar Streets.

The lone witness against Riddick at his 1992 trial was Shawn Stevenson, who testified that he saw Riddick on a fire escape shooting at Catlett with a rifle. (He has since recanted that testimony.)

Two types of bullets — .22-caliber and .32-caliber — were found in Catlett’s body, making it likely that two people fired at him.

Three days after the slaying, a fully loaded .22-caliber rifle that prosecutors now say they believe was Riddick’s was found near the scene. Cummings said ballistics testing determined that it was not the murder weapon.

Cummings said the agreement that led to Riddick’s release was an appropriate outcome “to further the interests of justice in this case.”

Riddick’s attorney, Emeka Igwe, disputed prosecutors’ contention that Riddick was an accomplice to the murder and said he was not involved with a gang. He said Riddick was an innocent man who was wrongfully imprisoned.

Riddick also told the judge: “I’m actually innocent of this crime.” He said Catlett was his friend.

Riddick also noted that 29½ years is a long time to be behind bars, and said he was looking forward to going home.

Cummings told the judge that she has been in touch with Catlett’s daughter, who declined to attend the hearing, but would be informed of the latest developments.

After the judge ordered Riddick’s release, a deputy sheriff allowed his wife, Dana, who married him while he was in prison, his mother, Christine, and his uncle, Clifford Smith, to hug him in the courtroom.

It took two more hours for Riddick to leave the Stout Center for Criminal Justice after paperwork was completed. Coming out of the courthouse, he said he felt “overwhelmed” and “grateful.” He thanked his family and his supporters.

Igwe called on Gov. Tom Wolf to grant Riddick a full pardon, saying further evidence in the case shows that Riddick is “actually innocent.”

Philadelphia City Councilmember David Oh, who has supported Riddick’s case and petitioned for his pardon, called this a “fantastic day,” but said Riddick was “forced” to plead no contest in the case so he could be freed.

Riddick’s case also got the attention of rapper Meek Mill, who was his former cellmate at the State Correctional Institution Chester. Mill was imprisoned there from November 2017 to April 2018 for probation violations related to a decade-old conviction on gun and drug charges. After his release, Mill spoke out in favor of Riddick to the media and on his social media.