This story has been updated.

The armed man who was chased by two Chicago police officers when they were fatally struck by a commuter train earlier this week has been charged in connection with their deaths, authorities announced Wednesday.

Edward Brown, 24, is facing two felony weapons charges, which include reckless discharge of a firearm-endangerment and aggravated unlawful use of a loaded weapon, police said. Brown will appear in bond court Thursday, the Associated Press reported.

Officers Eduardo Marmolejo, 37, and Conrad Gary, 31, were killed while investigating a report of shots fired on the city’s Far South Side shortly after 6 p.m. Monday, Chicago Police Superintendent Eddie Johnson said at a news conference later that night. Marmolejo was a two-and-a-half-year member of the force, and Gary had served 18 months, Johnson said. Their deaths, which officials called the latest “devastating tragedy” to befall the city’s embattled police force, bring the total number of Chicago police officers killed in the line of duty this year to four.

“When doing the most dangerous thing any police officer can do, and that is to chase an individual with a gun, these brave young men were consumed with identifying a potential threat to their community and put the safety of others above their own,” Johnson said. “During their investigation, both officers were struck by a passing Metra train and died instantly.”

The officers, described by Johnson as “heroic young men,” had been responding to a notification from ShotSpotter, a technology that detects and alerts police to potential gunfire, that shots were fired in a largely residential area about a mile south of Chicago State University. Authorities said that when Marmolejo and Gary arrived on scene, the man fled onto the nearby Metra tracks, prompting the officers to give chase on foot. The Metra is a commuter rail system that connects downtown Chicago to northeast Illinois.

Police spokesman Anthony Guglielmi said Tuesday that body camera footage from one of the officers struck by the train has shed some light on what may have happened, the Chicago Tribune reported.

Footage showed Marmolejo and Gary on the tracks discussing where the man they were chasing could have gone, according to the Tribune. As a northbound Metra Electric train approached, the officers moved onto tracks used by southbound trains, Guglielmi said.

“They must have thought the sound they heard was the northbound train,” Guglielmi told the AP. “They must have missed the sound of the train right behind them.”

Marmolejo and Gary were struck by a South Shore Line train around 6:20 p.m. Monday, the Tribune reported. The line, which goes from downtown Chicago to South Bend, Ind., is operated by the Northern Indiana Commuter Transportation District, but uses Metra tracks.

There is no stop at the location where the officers were struck and the train was estimated to be traveling between 60 and 70 mph, Johnson said Monday.

He added that the incident “highlights again how dangerous this job can be.”

“I often say that the most dangerous thing a police officer can do is take a weapon off an armed individual, and that’s what they were doing with no regard for their own safety,” he said.

About an hour after the officers' deaths were confirmed, Guglielmi tweeted that a “weapon was recovered and a person of interest is being questioned at the site.” Brown told police officers that he found a gun in a nearby alley and was “just testing it out," Guglielmi said, according to the Tribune. Guglielmi said Brown also mentioned firing the gun while on the tracks.

The last time an on-duty Chicago police officer was struck and killed by a train during an investigation was in 2002, according to the AP.

Chicago Mayor Rahm Emanuel spoke to reporters, struggling to find words to express the “immense sense of devastation to the Chicago Police Department.”

“We’ve lost two young men, both fathers with young families,” said Emanuel, his voice somber and muted. “This holiday will never be the same for those two families.”

He added: “There are no words that can express the grief, the sense of loss. It just knocks you back on your heels.”

On Tuesday, Guglielmi tweeted that Chicago Police Department bureau chiefs and district commanders joined detectives to “personally retrieve” the remains of Marmolejo and Gary from the railway. Gary’s funeral is scheduled for Friday and Marmolejo’s will take place Saturday, police announced Wednesday.

The deaths of Marmolejo and Gary come about a month after a 28-year-old Chicago police officer was killed during a shooting at Mercy Hospital that left three others dead, including the gunman. The officer, identified as Samuel Jimenez, had joined the department in February 2017 and was a father of three, The Washington Post reported. In February, Cmdr. Paul Bauer, who had been on the force for more than 30 years, was fatally shot as he tried to apprehend a fleeing suspect on foot in downtown Chicago, the Tribune reported. Bauer was shot six times, and the alleged shooter, a four-time felon, was arrested at the scene, according to the Tribune.

While noting that it has been an “immensely difficult year” for the Chicago Police Department, Johnson called attention to the officers of the city’s 5th District, where Marmolejo and Gary worked. This year, the 5th District, which serves neighborhoods on the South Side, had already lost three of its officers — two to suicide and one to a heart attack, the Sun-Times reported.

Chaplains and counselors were dispatched to the 5th District on Monday night in time to speak with officers during the midnight briefing, Johnson said. But he said that whatever the officers may be feeling won’t stop them from doing their jobs.

“The resolve of Chicago police officers always amazes me,” Johnson said. “As much as this hurts, I’m still immensely proud of them that they can continue on. They’ll be hurting, but they’ll still do the job they swore an oath to do.”

More from Morning Mix:

She swiped her co-worker’s Coke can. Police say it cracked a 28-year-old murder case.

In 2020 TV ad, Trump’s campaign manager asks people to call hotline to say, ‘Thank you, President Trump!’

New York Times assailed for Alice Walker interview endorsing ‘anti-Semitic’ conspiracy theorist