A New York man who was wrongfully convicted has been freed from prison after serving more than 24 years in prison for a shooting he didn’t commit.

“It was so difficult for me to be in prison for so many years when I knew the case against me was totally fabricated,” Pablo Fernandez, 47, told The Post. “I survived because of my faith in God, and because my family and my lawyers never stopped believing in my innocence.”

Fernandez was charged in the 1993 murder-for-hire slaying of gang leader Manny Quintero, 18, on a crowded Harlem street. He was just 22 years at the time. In 1996 he was convicted of the murder and sentenced to 25 years to life in prison.

The conviction was overturned last February after key witness Jesus Canela, said he’d been coerced into falsely identifying Fernandez by officer Albert Melino. According to the news outlet, Melino was under an active investigation for selling half a kilo of cocaine before joining the force.

Prosecutors then offered Fernandez time-served if he took a plea deal, agreeing to manslaughter but he refused. He remained in jail for six more months before a judge finally granted him $250,000. Fernandez posted bail and was released Aug. 2, but Manhattan Assistant DA Jeanne Olivo said that prosecutors would retry it. Over a month later, Olivio dropped the case.

“Our joy is bittersweet,” said defense lawyer David Brown. “The case against Mr. Fernandez was built from the beginning on police and prosecutorial misconduct, and perjury by government witnesses.”