It was an episode straight out of The Wire, complete with police corruption, evidence suppression and wrongful imprisonment. Only, this was reality for three men in Baltimore.

For many years, police records containing evidence that cleared three men of murder were sealed off in a white envelope bearing the logo of the police department of Baltimore and the words: “Police Emergency Only: Not to be opened for any reason.”

While serving a life sentence for the killing of 14-year-old DeWitt Duckett in 1983 over his basketball jacket, Alfred Chestnut, Ransom Watkins and Andrew Stewart were exonerated on 25 November upon the belated discovery of exculpatory evidence that proved their innocence.

“I sat on my bunk … and I cried,” Stewart said after being released from prison. “I didn’t know how to stop crying.”

The police records that were eventually made public revealed that the detective on the case, Donald Kincaid, withheld evidence that three of the four witnesses said they knew the murderer to be just one man who is now dead – not the three men who were convicted. It was also revealed that the witnesses, who were all under the age of 17, had failed to identify Chestnut, Stewart or Watkins from photographs.

It was the kind of tale of botched police work and endemic injustice on hard streets that inspired The Wire, the hit HBO crime series based in Baltimore.

And Kincaid even inspired a character in another cop show, Homicide: Life on the Street, where the character Beau Felton was loosely modeled on him.

Chestnut, Watkins and Stewart had each spent 36 years in prison before they were released this week, grinning and being cheered by supporters and loved ones, just months after their cases were suddenly reopened.

“There are elements of The Wire that were real. There were those neighborhoods and individuals that were corrupt in the police department, judiciary and political landscape,” University of Baltimore criminologist Jeffrey Ian Ross said. “The Baltimore police has always had recurrent challenges: dealing with violent crime, homicide, racial insensitivity and low morale,” he added.

Alfred Chestnut hugs his mother after his release in Baltimore. Photograph: Todd Kimmelman/Mid-Atlantic Innocence Project (/AFP via Getty Images

It was while he was languishing in prison that Chestnut watched an item on television about a case of miscarriage of justice and an exoneration in Baltimore.

It then prompted him to visit the prison library to learn about exoneration cases. He was rapidly convinced he had a case and filled out an application to the state’s attorney office, and attached a letter asking for help.

The application and letter landed in the hands of Lauren Lipscomb, assistant state’s attorney for Baltimore, on 16 May 2019. She was shocked as she read the letter and reviewed the newly unsealed police records in the case.

“I handed [the report] to my investigative detective, Brian Ellis, and said: ‘Are you seeing this?’” Lipscomb said.

She continued: “I’m wondering, ‘How did we get from one to three shooters?’ There were leads that explicitly named another shooter.”

Lipscomb said these factors quickly elevated Chestnut’s case from initial review into a full-blown investigation. “We began investigating and we quickly started finding that one thing led to another. Every single person we spoke to – none of them were consistent or supported that these three people were involved in this murder.”

Lipscomb’s actions then led to the Baltimore city state’s attorney, Marilyn Mosby, reopening the case.

Ross acknowledged Baltimore’s blighted criminal justice system.

“I’m not an apologist for police departments, but there’s pressure for closing cases, building careers and looking the other way,” he said, adding: “Withholding evidence is morally and ethically wrong and illegal. People’s lives have been lost. There’s been financial and psychological damage.”

It was on 23 November 1983, the day before Thanksgiving, that Baltimore police took the young witnesses to be interviewed in the homicide department without notifying their parents or guardians.

“They were all brought in as a group on multiple occasions to discuss what their testimony was going to be,” Lipscomb said. “At homicide, all of a sudden there was identification of all three defendants.”

On Thanksgiving Day 1983, all three men were arrested.

The case had been led by Donald Kincaid, who is now shown to have hidden evidence. It’s not entirely clear what motivated him to implicate the three men who ended up getting life sentences. He retired many years ago and denied any improprieties in an interview with the Washington Post.

We went through hell. It wasn’t easy Ransom Watkins

It wasn’t the first time Kincaid was involved in withholding exculpatory evidence. In 1982, in another case he was involved in, key witness statements that proved another man’s innocence were not disclosed. This omission led to the wrongful imprisonment of Wendell Griffin for the murder of James Williams Wise.

Griffin had already served more than 15 years when he finally got access to the police report on his case and realized investigators had evidence all along that could have proven his innocence. Upon being released from custody in 2018, Griffin sued the Baltimore city police department for damages and the case was settled.

After Chestnut, Watkins and Stewart were released this week, Mosby addressed them at a press conference.

“You should never have seen the inside of a jail cell,” Mosby said. “So on behalf of this system and in attempt to right the wrongs of the past, I apologize to you and your family for the pain you and they have had to endure because for this wrongful conviction.”

Watkins said: “We went through hell. It wasn’t easy. But people that loved us are standing here with us.”

When asked if Chestnut, Watkins and Stewart planned on pursuing legal action against the police, attorneys representing Watkins and Chestnut told said: “They are at a stage where they’re looking at all of their options.”

Watkins hinted at the press conference: “This fight isn’t over. My story doesn’t stop here on this corner.”

Although all are now free, Lipscomb expressed regret and sympathy for the closure the victim’s family never received.

“I explained to the victim’s family that a possible outcome would be that the three would in fact be released. I asked if they wanted to meet in person and that was declined,” Lipscomb said. “I’m acutely aware of how much the victim’s family did not want to hear from me.”

Two days ago, the three men spent their first Thanksgiving outside prison in almost four decades.

“This case is a very tough set of circumstances,” Lipscomb said. “There’s just no positive. We got to the bottom of it, but the casualties along the way – it’s not lost on me.”