The Chicago Police Department has opened an internal affairs investigation after a gun handed in during a turn-in event in 2004 wound up lying next to a Latin Counts gang member eight years later in the suburbs after he was shot dead by a cop.

William Stewart Boyd, a Cook County judge, turned in his late father’s .38 caliber Smith & Wesson revolver, serial number J515268, to a South Side church in exchange for a $100 Visa card, according to the Chicago Sun Times. The firearms acquired in the buyback program are supposed to be destroyed, but this one wasn’t.

“I’m doing the right thing,” said Boyd, “and, in the process, someone didn’t do what they were supposed to do. That calls into question the process. What’s happening after you turn these weapons in?”

The gun turned up next to the body of 22-year-old Cesar A. Munive, a gang member whose rap sheet included battery, sexual abuse of a minor and unlawful use of a weapon. He was shot dead on July 5, 2012 by Cicero Officer Donald Garrity, a policeman with a history of disciplinary problems, including allegedly threatening an officer after he was pulled over for driving nearly 90 miles an hour in a 30 mile per hour zone.

Around the same time, when he worked for a different department in Berwyn, Garrity was investigated for violating department policy when he allegedly wielded a “high-powered rifle” during a traffic stop. Records show the Munive incident wasn’t the first time he’d fired his weapon. In 2005 he shot a man who “brandished a shotgun at police officers.” He eventually resigned from the Berwyn Police Department and was hired by Cicero in 2012, the same year he shot Munive.

Munive’s family claims the officer planted the revolver to cover up an unjustified police shooting of an unarmed man. Cicero is set to pay the family a $3.5 million to settle a civil rights lawsuit.

Attorneys for the Munive family said there were “plenty of warnings readily available to any reasonable police department that it was not safe to put a gun in the hands of such an unstable individual.”

“No one would hire him except Cicero,” Munive family attorneys wrote in court documents.

Still, attorneys for Garrity deny he planted a weapon. Garrity and the other officer at the scene that day told investigators they were responding to reports of a gang fight. That’s when Garrity saw Munive riding away on a bicycle. When Garrity chased him, he said he saw Munive point a gun at the other officer – Dominic Schullo – who was sitting in a white, unmarked police car. Schullo said he was “staring straight down the barrel of the handgun.”

That’s when Garrity opened fire on Munive, hitting him in the back.

“He was gonna shoot me through the window,” Schullo told members of his department, talking about Munive. “If it wasn’t for Garrity, he would have shot me right through the glass.”

Garrity’s attorney said he was a hero after the shooting. He was promoted shortly after, and eventually left the department after developing PTSD.

“This police officer should not have been a police officer,” said Jon Loevy, the Munive family attorney. “They are going to pay a substantial settlement as a result of this . . . shooting.”

As for the revolver, Chicago Police spokesman Anthony Guglielmi called it “extremely abnormal and troublesome.”

“We are opening an internal affairs investigation today to trace this gun, verify that it was taken into police custody during a turn-in and investigate how it possibly ended up back on the street,” he said.