|The shootout took place at Moscow regional court.|
Russia's Investigative Committee said the five handcuffed defendants were being escorted by two guards in a lift when they made their move.
Svetlana Petrenko, from the investigative committee, said: "When the elevator reached the third floor, Russian National Guard officers were already there.
"In a shootout, one of the National Guard officers was wounded in the shoulder, three of the defendants were killed and the other two were seriously wounded and taken to hospital."
The defendants were reportedly members of the so-called Grand Theft Auto gang, named by the Russian media after the computer game.
A lawyer at the court, Sofya Rubasskaya, said: "I heard shots, there were more than 20 shots." She said that she saw a wounded female guard whose "face was all bloody".
Authorities said the incident took place before a hearing for the gang of nine, who are accused of the murders of 17 car drivers between 2012 and 2014.
Prosecutors said the gang members placed spikes on roads, forcing motorists out of their vehicles before shooting them dead.
They were also accused of two attempted murders, illegal production and possession of weapons and documents theft.
Tatiana Petrova, a spokeswoman for the Russian Interior Ministry's Moscow department, told TASS news agency that among those wounded were a Russian National Guard officer and two policemen.
"Two are members of the so-called GTA Gang. They have gunshot wounds of medium degree of gravity," she said.
The prosecutor's office said it was looking into the incident to see if the guards had violated the procedure for escorting defendants.