CNN  — 

A Pennsylvania man who spent 21 years behind bars for murder was freed Wednesday after the star witness in the case confessed to the killing.

John Miller walked out of the State Correctional institution in Frackville, about 100 miles northwest of Philadelphia, after prosecutors declined to retry him, saying there was insufficient evidence, according to court records.

“I’m very happy and excited that after 21 years I’m finally being heard and that my innocence has reached the surface,” Miller said in a written statement distributed by his attorney. “I’m going home to my family. I’m overwhelmed, excited, and happy.”

Miller, 44, credited his attorneys with securing his release after years of declaring his innocence.

John Miller has always maintained his innocence.

“Without them, I don’t know what would have happened or where I would have been,” he said.

Miller was convicted in 1997 for the October 1996 murder of Anthony Mullen during a robbery attempt outside the 30th Street Station, Philadelphia’s main railroad station, according to court records. Mullen had been shot to death. A jury convicted Miller of second-degree murder, and he was sentenced to life in prison.

David Williams was the witness who identified Miller as the killer, according to court records. Williams told police in exchange for leniency in another case that Miller had confessed to him that he killed Mullen, the court records show.

‘I can’t live with this on my conscience’

But Williams recanted his statement even before Miller’s preliminary hearing, and “he has been confessing to Mullen’s murder for more than a decade,” the Philadelphia District Attorney’s Office wrote in a motion filed Monday that declined to retry Miller.

Williams even sent a letter to Miller’s mother in December 2002, saying in it that he committed the murder.

“I can’t live with this on my conscience. Your son had no knowledge of this crime. He wasn’t even there. I lied on him,” he wrote, according to court records.

Miller filed 10 appeals, his attorney, Thomas Gallagher said. All were denied, he said.

Miller’s legal team, which included the Pennsylvania Innocence Project, took on the case eight years ago and found evidence that had not been previously disclosed to Miller’s defense team, Gallagher said in a news release. That evidence raised questions about what authorities knew about Williams initial testimony, according to court records.

A federal judge on July 1 ordered Miller be released, subject to a decision by the district attorney on whether to pursue a new trial.

‘Insufficient evidence’ to make a case

In a motion filed this week, the District Attorney’s Office said there was “insufficient evidence” to make a case against Miller.

“Williams’ statement to the police was the crux of the case against defendant,” the motion said.

On Wednesday, a Common Pleas Court judge agreed and ordered Miller released.

CNN was unable to reach Williams for comment, and it was not immediately known if he had an attorney. The District Attorney’s Office has not said whether it will charge Williams in the Mullens murder.