Three judges have been shot dead at a court in China's southern Hunan province by a man armed with a submachine gun, reports say.
Three other judges were injured before the man, who was also carrying two more weapons, killed himself.
Officials told the BBC the attacker was a 46-year-old local man who worked as head of security at a post office.
Correspondents say shootings are relatively rare in China, as few people have access to firearms.
The shooting happened during just before 1000 (0200 GMT) at the Lingling District People's Court, said Xinhua.
The BBC's Chris Hogg in Shanghai says the man, named by officials as Zhu Jun, had reportedly borrowed his weapons from a colleague saying he needed to inspect them.
He barged into an office at the courtroom and opened fire on the officials.
A spokesman for the local propaganda department told the Associated Press news agency the judges had been discussing a case unrelated to the gunman.
Xinhua said the man had been motivated by revenge - he was reported to have divorced his wife three years ago and was unhappy at the way the court divided their wealth.
China has seen a series of knife attacks in school in recent weeks which have left 17 people dead and dozens injured.
The country has in the past had a comparatively low rate of violent crime, meaning the recent violence has been all the more shocking.