A police officer and two female staffers were killed in a shooting at a Chicago hospital on Monday afternoon.

Chicago Police Officer Samuel Jimenez was shot and killed after he responded to calls of an active shooter at Mercy Hospital and Medical Center, Police Superintendent Eddie T. Johnson said Monday night.

A doctor was shot after she engaged in a verbal altercation in the parking lot with a man with whom she was in a relationship at about 3:30 p.m. (4:30 p.m. ET), Johnson said. A third person, a friend of one of the couple, intervened but fled into the hospital when the gunman lifted his shirt and displayed a handgun, he said.

When police arrived, the gunman, who police sources familiar with the investigation identified to NBC Chicago as Juan Lopez, fired multiple shots at officers before they could exit their squad car, Johnson said. He then also fled into the hospital.

Lopez, 32, exchanged gunfire with police for several minutes inside the hospital, Johnson said. Jimenez, a pharmaceutical assistant and the gunman were all fatally shot during the confrontation, he said.

It remained unclear Monday night whether the gunman died from police gunfire or from a self-inflicted wound.

"Those officers that responded today saved a lot of lives, because this guy was just shooting," Johnson said. "That poor woman that got off an elevator had nothing to do with nothing, and he shot her. Why?"

Mayor Rahm Emanuel told reporters Monday night: "The city of Chicago lost a doctor, a pharmaceutical assistant and a police officer — all going about their day, all doing what they love. This tears at the soul of our city. It is the face and the consequence of evil."

A witness, James Gray, told NBC Chicago that he saw at least one woman get shot. Gray said he saw a man and a woman talking to each other before the man pulled a gun and shot the woman and then began shooting others at the hospital, which is about 25 blocks south of the Chicago Loop.

"There were people sitting in the waiting area, all stood up, turned and started running towards the front of the hospital, and security was trying to direct us into rooms and tell us to lock the doors behind us," Gray said. "It was chaos. It was just mass chaos."

"It looked like he was turning and pointing at people at random, like he wasn't shooting any one person," Gray said. "He just started shooting — bam!"

Tracy Lyons, another witness, said she had just finished a radiation treatment when "all of a sudden, you hear five to six gunshots — pow, pow, pow, pow, pow."