For two years, Kamari Belmont was in a Cook County jail unit reserved for Chicago’s most dangerous criminals. A looming murder charge meant the 23-year-old might never breathe free air again.

Instead, a slip-up at the state’s attorney’s office bounced in his favor. The murder charge was dismissed, and Belmont walked out of the jail onto California Avenue.

Minutes later, he was dead, killed in a hail of gunfire in a shooting the Chicago Tribune said had “all the appearances of a well-planned hit.”

Belmont staggered from a car trying to find help, but it was too late. He collapsed and died on the ground, not far from 20 spent shell casings and the jail that had held him since 2015, his attorney told The Washington Post.

Belmont was brought into the Cook County Correctional Center two years ago, after he and another man were accused of two botched robberies in one night.

The duo scuffled with a 40-year-old man on Vincennes Avenue and shot him in the leg before running off, according to the Chicago Tribune. Later that night, police say they think the duo tried to rob a couple near the Loop, but that incident also had complications. A woman ran and flagged down a police car. Officers were able to track the suspects using a tracking application on a stolen cellphone, according to the Chicago Sun Times. They arrested Belmont and his alleged accomplice for both robberies at once.

Belmont was booked into prison, charged with attempted murder and several counts of robbery.

Things soured for the robbery victim who had been shot in the leg. He died three weeks after the shooting, Belmont’s attorney, Michael Johnson, told The Washington Post. Belmont’s charge had morphed into a murder accusation.

But not on paper. The state’s attorney’s office took too long to file indictment paperwork for the murder charge, a violation of a state law that guarantees defendants a speedy trial, Johnson said.

“The fellow died in late May of 2015,” Johnson said. “The state does not indict them for the murder until May of 2016 — way beyond the statutory timeline for them to bring the new indictment.”

A spokeswoman for Cook County State’s Attorney Kim Foxx, told ABC-affiliate WLS-TV that a handling error happened during the administration of Foxx’s predecessor.

“As a result, case law demanded that we dismiss the murder charges,” spokeswoman Tandra Simonton told the news station. “Going forward, we are working to improve training protocols for our prosecutors to prevent such errors.”

Belmont’s attorney explored the technicality and then filed a motion for dismissal. A judge agreed, and suddenly, Belmont found himself facing just the robbery charge.

It took family and friends a month to raise the $10,000 needed to spring him from jail.

On March 6, a friend posted bail about 5:30 p.m. But being released from the 10,000-person correctional facility can take hours, so a friend came back to pick him up before midnight.

Jail video released to news outlets showed Belmont walking out of the jail alone, wearing a gray hoodie.

He was being driven away from jail when a white SUV pulled up, and the people inside opened fire, Johnson said. The suspects’ SUV crashed, and the gunmen fled.

It’s unclear who lay in wait for Belmont, or their motives. Police spokeswoman Officer Laura Amezaga told The Post that Belmont’s murder case remains open. No one has been arrested, and police haven’t released the names of any suspects.

That hasn’t stopped speculation about the unusual circumstances of his death. His attorney and court documents obtained by the Tribune identified him as a gang member — belonging to the 4-6 Terror faction of the Gangster Disciples, which had been recently feuding with rival gangs.

It’s possible that gang tensions simmered while Belmont was in jail — but they could have just as easily fizzled with Belmont off the street not committing crimes, Johnson said. There were two other people in the car when the shots were fired who could have also been targets.

Family and friends may know more, but Johnson said that he hadn’t talked with them since Belmont was killed.

The attorney had discovered the technicality months ago, but it was up to his client to raise the bail money, a potentially lengthy process.

“I thought he was still in jail until a reporter called me morning, saying do I know Kamari Belmont,” Johnson said.

Belmont was out of jail, the reporter said. And he was dead.

Read more: 

A crooked cop’s execution-style killing in Texas exposes the ruthless inner workings of the Mexican Mafia

He once killed a man in a road rage incident. Now, he has died in one.

A family has searched for a missing woman for months. They keep finding other people’s bodies.

A family suspected a caregiver was abusing an Alzheimer’s patient. So they installed a camera.