Sheldon Thomas spent more than 18 years in prison because he was mistaken for a different person with the same name.
CNN  — 

A 35-year-old man who spent almost 19 years wrongfully imprisoned for murder after detectives misled a witness into identifying the wrong person, is now free.

Sheldon Thomas, who was convicted of killing a 14-year-old boy on Christmas Eve in 2004 in New York City, had his conviction overturned and the indictment vacated Thursday – years after an eyewitness identified him after being given a photo of the wrong Sheldon Thomas, according to a statement from Brooklyn District Attorney Eric Gonzales.

When the botched identification came out in court at the time, a judge said there was still probable cause for the arrest and that the photo had enough of a resemblance, Gonzalez said.

Thomas was only 17 when he was arrested and charged for the murder, records show.

His exoneration followed an extensive investigation by the Brooklyn DA’s Conviction Reversal Unit, according to the DA’s office.

Gonzales said the case against Thomas “was compromised from the very start by grave errors and lack of probable cause to arrest Mr. Thomas. He was further deprived of his due process rights when the prosecution proceeded even after the erroneous identification came to light, making his conviction fundamentally unfair.”

“There’s so many times when I was in my cell I would think of this moment,” Thomas said in court Thursday. “Right now, I’m just speechless.”

Thomas was one of three alleged gang members accused of killing teenager Anderson Bercy and wounding another person, according to the DA’s office.

Detectives asked to use a photo of Thomas from a gun arrest months earlier so they could show an eyewitness as part of an array of photos, the DA’s office said.

Before they obtained that photo, the detectives decided to pull a photo from a police database that was in fact of a different Sheldon Thomas, according to the office.

The eyewitness identified that photo in the array as the shooter, not knowing that it was the wrong Sheldon Thomas, according to Gonzales.

Detectives had originally asked to use the photo of Thomas from a prior arrest, right, for the photo array, but before they obtained it, decided to pull a photo that was actually of a different Sheldon Thomas, which is the photo on the left.

Detectives went to Thomas’ address – not that of the Sheldon Thomas whose photo was actually used – and arrested him, according to a report from the DA’s Conviction Reversal Unit. Two others were also arrested in connection with the killing.

That same eyewitness then identified Thomas in a police lineup, not knowing that the photo and the person she saw in the lineup were two different people, Gonzales said.

During a pretrial hearing in 2006, the detective on the case admitted during cross examination that he used a photo of the wrong Sheldon Thomas, admitting that he falsely testified, Gonzales said. Another detective then said Thomas told them he was not the man in the photo, according to the DA’s office.

At that time, the judge said there was still probable cause because of the anonymous tips, adding that the photo resembled Thomas, despite it being of a different person.

Before the trial started, charges were dismissed against the other two arrested for the murder.

Thomas was found guilty of a slew of charges, including one count of second-degree murder, five counts of attempted murder and weapons charges. He was sentenced to 25 years to life.

When he was given the chance to speak before the sentence was handed down, Thomas stated one more time that he was innocent, according to the CRU report.

Years later, the Brooklyn DA’s CRU re-interviewed the witnesses in the case in their own investigation, according to the DA’s office.

They determined that Thomas was denied due process at every stage, making the conviction fundamentally unfair, according to the report. The CRU also determined that the detectives on the case repeatedly harassed Thomas after his gun arrest, which contradicted their testimony that they had never even seen Thomas, according to the DA’s office. The report also pointed out “prosecutorial missteps, and counsel’s failures.”

“Each of these errors, on its own, deprived defendant of a fair trial,” the report concluded. “Together the errors undermined the integrity of the entire judicial process and defendant’s resulting conviction.”

Since 2014, the unit’s work has resulted in 34 convictions being vacated. There are currently 50 open investigations, according to a DA’s office spokesperson.

“We must strive to ensure fairness and integrity in every case and have the courage to correct mistakes of the past,” Gonzalez said in his statement.

An attorney for Thomas did not immediately respond to CNN’s request for comment.