Demetrius Smith knew a man had been murdered in his neighborhood. But that's all he knew — until two police trucks pulled up on a warm summer morning and whisked him to the homicide division at police headquarters.

Detectives had rounded up two people who said they saw Smith shoot 36-year-old Robert Long to death near a set of Southwest Baltimore train tracks in March 2008.

"I thought it was a joke," Smith said, recalling the moment when he read the brief statement of charges that had been slipped under his door at Central Booking.

Five years would pass before Smith walked free, exonerated by a federal investigation that began with an old lead.

When he died, Long was an informant in a Baltimore police investigation of a scheme to steal construction materials. City homicide detectives had disregarded that connection, and Smith still can't understand why authorities were so quick to point the finger at him.

"I sat in there five years, back and forth … for court in chains, shackles," Smith, 30, said in his first interview since being set free. "All of that for nothing."

Wrongful-murder convictions are rare, but each one raises questions about the legal safeguards in place to protect innocent people. At least 15 convicted killers have been exonerated in Maryland over the past 20 years.

Investigative documents from Smith's case, reviewed by The Baltimore Sun, show how a few missteps and wrong turns can lead to an unjust outcome: Detectives following one lead fail to account for another. Witnesses lie in court. Prosecutors sell jurors on a bad case.

"When you study these exonerations, it's really humbling to see how many ways people err," said Brandon L. Garrett, a University of Virginia law professor who studies wrongful convictions.

Long's mother, Grace Bouvier, sat through the trial and believed Smith when he looked her in the eye and said he was innocent. Nobody who knew Long would have believed the story laid out by authorities in court, she said.

"I blame the Police Department and I'm pretty sure [Smith and his family] do too," Bouvier said.

City police and prosecutors defend their handling of the case, arguing that they never anticipated what a federal investigation would turn up.

"Officers follow a strict set of protocols when investigating homicides in conjunction with other agencies, and we're confident that's what happened in this case," said J. Eric Kowalczyk, a Baltimore police spokesman. "After a state trial, clearly the federal government found that facts had changed."

Even before he died, Long was on the Police Department's radar as a defendant and potential witness in a series of thefts from construction sites. In the weeks before his murder, Long had been interviewed by a special police task force that investigates thefts. He told detectives what he knew about Jose Morales, his boss and co-defendant.

Officers told Long to keep his cooperation quiet, but he told a few friends and word drifted back to Morales. Long had also called his mother in Texas and said he was working with the police.

"I told him, 'Son, be careful, he'll kill you,'" Bouvier recalled. Long told her he'd never do it. "He won't kill you, but he'll have somebody else do it," she warned.

Long was found behind Traci Atkins Park on the day after Easter with two .25-caliber bullet wounds to his head, along with heroin and cocaine in his system. Years later, the remote location is no less gritty. A rail car stands rusting on a set of tracks that lead nowhere; nearby is a pile of discarded railroad ties.

Baltimore homicide detectives Steve Hohman and Charles Bealefeld arrived at that scene in 2008 and set to work in a morning chill.

Bouvier rushed to Baltimore and quickly sat down with Hohman to share her suspicions about Morales. Hohman also learned that a man who worked with Morales owned a .25-caliber gun and that the weapon had gone missing after the murder.

The detective convinced a judge to issue a court order for Morales' phone records. He later told investigators he also spoke to the man who owned the gun, and according to records, formally interviewed the man's brother. They both admitted to being with Long the night before he died. But Hohman did not approach Morales, according to police files, and he later said he never got the phone data.