An inmate being taken for treatment at a specialty hospital shot a deputy sheriff after a struggle over the officer's gun Wednesday, then was shot and critically wounded by a second deputy, police said.

Boston Police Commissioner Ed Davis said the shooting happened around noon in the emergency room of the Massachusetts Eye and Ear Infirmary. The two officers from Middlesex County were removing the inmate's handcuffs when the man grabbed for the gun of one of the officers, he said. During the struggle that followed, one of the deputies was shot in the leg.

The other deputy sheriff then fired his weapon, striking the prisoner in the chest, Davis said.

The officer was taken to nearby Massachusetts General Hospital, where he was in stable condition. The inmate, taken to the same hospital, was believed to be in critical condition.

Authorities didn't immediately release the names of the officers or inmate, but Davis said no one else was involved.

"It's all been contained," Davis said. "Everybody is either in the hospital or in custody."

Jennifer Street, a spokeswoman for the Massachusetts Eye and Ear Infirmary, said the hospital remained open, but the emergency room was closed as authorities investigated.

A spokesman for the Middlesex County sheriff's office said it expected to issue a statement later Wednesday.

Boston is located in Suffolk County, and the Suffolk district attorney's office is working with police on the investigation.

-- Audio report below by WBUR's Martha Bebinger: