His lawyer says Edward Brown found a handgun in a fanny pack and decided to fire it out of curiosity.
But the sound of gunshots on the city's South Side apparently drew the attention of two Chicago police officers who pursued Brown, ran onto train tracks and were fatally struck from behind by a Metra train , authorities said.
Brown has a $200,000 bond after a court hearing on Thursday afternoon.
"It's his first arrest of his whole life and my client had no intention for anyone to get hurt," said attorney Frank Kostouros. "Ultimately, he's a good kid who made a mistake."
Brown, 24, faces a charge of reckless discharge of a firearm and aggravated unlawful use of a weapon, both felonies.
The two officers responded Monday to a shots-fired call -- issued after a ShotSpotter sensor detected gunfire -- and followed Brown, who ran onto the train tracks, Chicago police said.
Prosecutors said the suspect found the fanny pack carrying a .380-caliber gun and ammunition after it was dropped by someone taking out the garbage.
Brown took the contents home and then decided to fire it by the tracks, said Cook County Assistant State's Attorney Guy Lisuzzo.
"Curiosity got the best of him," said Kostouros, who said his client was not aware of the officers' presence.
Body camera audio indicates that officers Conrad Gary and Eduardo Marmolejo were aware of a northbound train in the area during the chase, but they did not realize a southbound train was approaching, according to police Superintendent Eddie Johnson.
The noise from the northbound train apparently masked the sound coming from the other train, said police spokesman Anthony Guglielmi. There's no indication the officers saw the southbound train before it struck them, he said. It was traveling at 60 to 70 mph.
Gary, 31, had been on the force 18 months. Marmolejo, 37, joined the department 2½ years ago, Johnson said.
Brown has no criminal background and works as a prep chef at a restaurant downtown, according to information gleaned during Thursday's court proceedings.
The next court date is scheduled for December 27.