NEW YORK (CNN) -

After more than two decades behind bars, David Ranta walked out of a Brooklyn courthouse Thursday afternoon with an apology from a judge and one immediate wish: "Get the hell out of here."

Ranta had been convicted of second-degree murder in 1991 for killing a rabbi during a botched diamond heist. But two decades later, a onetime witness said he had been coached into identifying Ranta in a police lineup -- and after an investigation, prosecutors recommended that Ranta's conviction be tossed out.

"Mr. Ranta, to say that I'm sorry for what you have endured would be an understatement and grossly inadequate, but I say it to you anyway," Judge Miriam Cyrulnik said during an emotional hearing that left even the judge wiping her eyes.

Asked what he wanted to do now, Ranta told reporters at the courthouse, "Get the hell out of here." And with that, he walked out with his lawyer, carrying a small mesh bag that held his belongings.

"Right now, I feel like I'm under water swimming," he said. "This is overwhelming."

Hours later, his lawyer told CNN that Ranta intends to file a federal civil rights lawsuit against the city of New York and the New York Police Department.

"My client had 23 years taken from him. It is a lifetime, it's a generation," attorney Pierre Sussman said. "And if you look at those before and after pictures, before he went in, and now that he's out, it's a different person."

For now, Ranta plans to relax and reconnect with his family, Sussman said.

One of his first requests after leaving the courtroom, Sussman said, was "a juicy chicken parmesan sandwich with a side of fries."

'A number of things' wrong with the case

Ranta, now 58, was sentenced to 37 1/2 years to life in prison in the killing of Chaskel Werzberger, a rabbi in Brooklyn's Williamsburg community.

Since Ranta's trial, another man's widow has identified her now-dead husband as the killer; a onetime jail inmate has said he made up statements about Ranta to boost his own fortunes; and the man who, as a boy, picked him out of a lineup has come forward to say he was coached by a detective.

Prosecutors have determined the evidence underpinning Ranta's conviction "has been degraded to such an extent" that it would no longer support the verdict, said John O'Mara, the deputy district attorney in charge of Brooklyn's conviction integrity unit.

Louis Scarcella, one of the detectives who investigated the case, told CNN that Ranta admitted his involvement in the heist attempt and that he stands by the arrest. As for claims that police coached a witness, he said, "No way that happened."

But O'Mara said the investigation found "a number of things that were wrong with the case."

"It was cumulative," he said. New evidence led prosecutors to believe "that we could no longer be confident" that Ranta was guilty beyond a reasonable doubt.

A witness changes his story

A key part of the investigation that led to Thursday's ruling started two years ago, when a witness in the case changed his story.

Menachem Lieberman was 13 years old when he identified Ranta in a lineup.

In 2011, he told investigators that he identified Ranta after being told by a detective to "Pick the guy with the big nose."