Footage from the scene shows people leaving Milan's court building
As many as four people are reported to have died after a man opened fire at the Palace of Justice in the Italian city of Milan before being arrested.
Officials said the gunman, identified by local media as Claudio Giardiello, was a defendant in a bankruptcy case.
The Ansa news agency said he shot a bankruptcy court judge, a lawyer and one other man. The fourth person is thought to have had a heart attack.
The suspect was arrested in the suburb of Vimercate as he fled on a motorbike.
Interior Minister Angelino Alfano said the "presumed assassin" was now being held at a carabinieri military police barracks in the Milan area.
The sound of gunfire sparked panic inside the Palace of Justice on Wednesday morning, with hundreds of people pouring down stairways towards the exits while police and military police officers searched for the gunman.
"All of a sudden we heard at least three or four shots," lawyer Marcello Ilia told the AFP news agency outside the building.
Women were first to be evacuated by police from the Palace of Justice
"We tried to find out what was going on. There were suddenly lots of police officers who told us not to leave the room, they shut us in," he said.
"After a few minutes we came out. They told us someone in a suit and tie was armed and at large in the court."
Appeals court judge Giovanni Canzio told Ansa that the gunman had opened fire at the entrance to a courtroom before moving to another part of the building. He identified the dead judge as Fernando Ciampi.
Citing officials and witnesses, the newspaper La Repubblica reported that the gunman had been attending a bankruptcy hearing when a fight broke out inside the third floor courtroom.
He then pulled out a weapon and shot the lawyer, whom it named as Lorenzo Alberto Claris Appiani, as well as another man, it said. The lawyer was hit in the chest and died soon afterwards, while the second victim died of his wounds in hospital.
The gunman then left the courtroom and headed to the office of Mr Ciampi, where he opened fire at the judge, La Repubblica added.
The court building is in the centre of Milan, only a few streets away from the city's cathedral
A fourth person was found dead inside the building after apparently suffering a heart attack, possibly brought on by the shooting.
After hiding inside the Palace of Justice for more than an hour, the gunmen fled on a motorbike, according to La Repubblica. He was arrested by carabinieri officers in Vimercate, about 25km (15 miles) to the north-east of central Milan.
It was unclear how the gunman managed to gain entrance to the Palace of Justice with a weapon, as visitors have to pass through metal detectors.
Lawyers and courthouse employees with official identification are, however, regularly waved through, according to the Associated Press.
Ansa reported that one of the metal detectors was broken on Wednesday morning.
"It's disturbing that just anyone can get into the Palace of Justice armed," said the head of the Lombardy region, Roberto Maroni.
"The fact that we're not talking about an organisation which surveyed the place first makes it even more perturbing."
The Palace of Justice is in the centre of Milan, only a few streets away from the city's cathedral and main shopping district.