BOSTON — A deputy sheriff was shot in the leg and a prisoner he had been transporting to a Boston hospital for treatment was in critical condition on Wednesday after the prisoner grabbed for the deputy’s gun and fired, Boston Police Commissioner Ed Davis said.

The shooting occurred when two deputies who had transported the prisoner to Massachusetts Eye and Ear Infirmary removed his handcuffs after bringing him to the emergency room, Davis said.

“The two individuals fell to the floor, a round was fired and one of the deputy sheriffs suffered a gunshot wound to the leg,” Davis told reporters outside the hospital where the incident occurred.

The second deputy shot the prisoner at close range, Davis said.

The Boston Police Department did not disclose the identities of the prisoner or the deputies.