"Inside the emergency room, as the handcuffs were being taken off the suspect, he began to struggle for a gun. There was a fight. ... The two individuals fell to the floor and a round was fired," he said.

The gun went off during the struggle, striking the deputy in the leg. The other deputy then shot the inmate in the chest, police said. The prisoner is currently in critical condition at Massachusetts General Hospital.

Some witnesses reported hearing as many as six gunshots.

"I heard five gunshots," one witness who was across the street from the hospital told Boston.com. After the shooting stopped, there was "just a lot of people running out of the lobby."

A woman who was in the emergency room at the time of the shooting gave a similar account of what happened.

"I heard them trying to control somebody first and then I heard shouting and then I heard the gunshots. It was at least four to six," she said.

The emergency room was closed briefly before being reopened Wednesday evening.

"We are very confident that the Mass. Eye and Ear emergency room is safe tonight," Jennifer Street, the hospital vice president for communications, told Boston.com. "Understandably, we are also caring for staff who were visibly shaken today, but they are doing quite well."