A gunman who opened fire inside a Milan courthouse killing at least three people has been arrested at the end of a police chase.

Italian police said they have held Claudio Giardiello, a defendant in a bankruptcy case, in Milan's northeastern suburb of Vimercate as he was fleeing on a motorcycle.

Giardiello allegedly fired a gun at a lawyer, a witness and two members of the public during a hearing inside the Palace of Justice, which is located in the city centre of Italy's business capital.

He then reportedly ran out of the courtroom to reach a judge's office located on another floor, shooting him dead before fleeing the scene.

Hundreds of people poured out into the streets outside the building as it was evacuated by police that cordoned off the area, patrolling all exits.

Initial reports suggested the shooter was hiding inside the courthouse, but Carabinieri police later said they arrested him in Vimercate, located more than 25km from the Palace of Justice.

Meanwhile two of the victims have been named as Judge Fernando Ciampi and Lorenzo Alberto Claris Appiani, a lawyer.

Police said two people were also wounded in the initial shooting. Ansa news agency named them as Giardiello's co-defendants Giorgio Erba e Davide Limongelli, who are uncle and nephew.

Another man who suffered a stroke during the incident was reportedly taken in critical conditions at a local hospital.