Three other people were wounded in the shooting at New Delhi's sprawling Karkardooma court complex, which is meant to be a high security zone.
"There were four men who started shooting randomly inside court room number 73," a senior police officer told AFP on condition of anonymity.
India court orders seven to hang for Nepali woman's rape, murder
"A head constable has died and three others are wounded. It appears to be a case of rivalry between two local gangs."
Six to seven rounds were fired when the accused, who has been charged with around 100 offences, was being produced before a metropolitan magistrate.
Indian court declines to lengthen jail time for Delhi gang rape convict
The gunmen were taken into custody after they were apprehended by lawyers and police who were on duty at the premises, the source said.
Last year, another accused was shot dead inside a district court in the Delhi suburb of Noida.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ