Five defendants were in a lift in the Moscow regional court building when they seized the weapons from the two officers escorting them, the Investigative Committee, the state body which handles serious crimes, said in a statement.
When the lift stopped on the third floor of the building and the doors opened, three of the defendants tried to escape but were shot dead by Russian national guard officers. The two others defendants were seriously wounded, the statement said.
Three law enforcement officers were hurt, one of them with a gunshot wound. Two of the three were taken to hospital.
The defendants are accused of being members of a group, dubbed in Russian media the Grand Theft Auto Gang after the computer game. Prosecutors allege the group was responsible for a series of vehicle thefts that in several cases involved killing the cars' owners.
The group, made up of people originally from ex-Soviet Central Asia, is accused of committing 17 murders, banditry and other grave crimes, the Investigative Committee said.
One of the group had fought for Islamic State in Syria before coming to Russia, official TV channel Rossiya 24 said on Tuesday, citing a source in law-enforcement bodies.
(Reporting by Denis Pinchuk and Maria Tsvetkova; Writing by Dmitry Solovyov; Editing by Christian Lowe/Jeremy Gaunt)
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)