As police exchanged gunfire with the gunman at a hospital on Chicago's South Side on Monday, one officer escaped injury by inches.

Chicago Police Officer Samuel Jimenez, 28, who was married with three children, was killed after being shot in the lobby of Mercy Hospital when he responded to a call about the shooting, officials said. Two other hospital workers, Dr. Tamara O'Neal and Dayna Less, 25, a first-year pharmacy resident, were also killed in the shooting.

A second officer was also shot at while responding to the hospital, but was not injured because a bullet struck his holster and embedded itself in his gun, FOX 32 reported.

A photo released by police that appears to show the bullet hole in the officer's holster and the bullet lodged in his firearm.

Chicago Police Superintendent Eddie Johnson said at a press conference Monday night that the officer was not injured, adding that a squad car was also hit by gunfire. The attacker, identified by police as 32-year-old Juan Lopez, also died Monday but it was not clear if he took his own life or was killed by police.

"Those officers that responded today saved a lot of lives," Johnson said. "They were heroes because we just don't know how much damage he was prepared to do."

CHICAGO HOSPITAL SHOOTING THAT LEFT OFFICER, DOCTOR DEAD CAME AFTER FIGHT OVER RING, 'BROKEN ENGAGEMENT': REPORTS

While officials have not said what motivated the rampage, it appears that it was sparked over an apparent "broken engagement," the Chicago Tribune reported. O'Neal had called off her engagement with Lopez in September, and the shooting spree began with a confrontation between the two in the parking lot about a ring, witnesses said.

Dr. Tamara O’Neal, Chicago Officer Samuel Jimenez, and Pharmacy Resident Dayna Less were killed in the shooting.

Dr. Tamara O’Neal, Chicago Officer Samuel Jimenez, and Pharmacy Resident Dayna Less were killed in the shooting. (Franciscan Health/Chicago Police/Facebook)

The officer killed in the shooting had joined the department in February 2017 and didn't work in the hospital area, but responded when he heard shots were fired. Chicago Police Anthony Guglielmi said Jimenez's actions showed it "speaks volumes about his character."

Sgt. Larry Snelling, who is assigned to the Chicago police academy, told the Tribune the 28-year-old was "well rounded" and on top of his training.

“He was well-rounded,” he told the paper. “He was one of the guys we didn’t have to worry about at all. Just a great kid. The more I think about him, the more I remember about him. ... Very professional, outstanding recruit.”

The Associated Press contributed to this report.