The victims were a 57-year-old lawyer and his client, a 31-year-old man who was in a custody battle with the gunman's daughter, police and court officials said.
The gunman was arrested nearby and police seized a rifle used in the shooting, officials said.
"It is a family tragedy, not an attack on the court or the legal system," said Soeren Axelsen, head of the Copenhagen City Court.
Authorities didn't release any names. The shooting happened in the Bailiff's court, which is part of the city court.
Also Read
He was taken to a hospital with serious wounds, but his condition wasn't life-threatening, police said.
The lawyer was pronounced dead at the scene.
Police cordoned off several streets around the building, which is next to City Hall.
The Ekstra Bladet tabloid posted a photo on its website showing a police officer aiming a weapon at a person on his knees, saying it showed the suspect being arrested.
Security is normally lax in Danish courts except for court sessions related to terrorism, criminal gangs and high-security cases where everyone but lawyers and judges must walk through metal detectors.