Head Constable Ram Kumar, who was accompanying undertrial Chenu Phelwan alias Irfan, received three bullet injuries to his head and chest and died on the spot. Over six rounds were fired by the assailants.
The incident occurred around 11 am when Irfan was being produced in court room no. 73.
"The gang entered the court and opened fire when they saw Irfan. He was injured and has been hospitalised," Joint Commissioner of Police (Eastern Range) Sanjay Beniwal said.
"Unfortunately, the policeman accompanying Irfan got killed," he said. "Irfan belongs to another (criminal) gang."
An eyewitness, Sushil Kumar, told NDTV, "Four young men started firing and the police constable got hurt. Everybody started running away. A mauser and a desi handgun were lying outside."
A clerk present in the court also sustained injuries in the firing.
Police are questioning the assailants, who were caught by lawyers and security personnel, as they tried to flee.
Follow NDTV for latest election news and live coverage of assembly elections 2019 in Maharashtra and Haryana.
Subscribe to our YouTube channel, like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.