The suspect, John Pope, appeared in court in central Cebu city to face the charges when he pulled out a gun and shot a lawyer and a physician who filed a case against him, police said.
He then fired at a prosecutor in the hallway of the building before police fatally wounded him, said police Chief Mariano Natuel.
Regional police director Marcelo Garbo said Pope ignored orders to surrender and tried to fire at police.
The Philippine Star reported on its website Tuesday that Pope, who was in his 60s, was carrying two firearms — a .357 revolver which he used to shoot the victims, and a .45 pistol police later recovered from a bag he carried.
Police said they were investigating Pope's background.
Canada's Department of Foreign Affairs said Canadian officials were in direct contact with Philippine authorities and were providing consular assistance to Pope's family.
"Our deepest sympathies are with those affected by the terrible event in the Philippines," said spokeswoman Amanda Reid.
Philippine media reported on Pope in 2011, when he was held by police on charges of illegal possession of firearms. The same physician who was killed in Tuesday's shooting accused Pope, his neighbour, of brandishing a weapon and threatening him and other residents in their condominium.
Pope was quoted as saying at the time that the pistol he was carrying was for self-defence. Apart from illegal weapons possession, he was also charged with malicious mischief and grave threats.
The Freeman, an English newspaper in Cebu, reported online Tuesday that Pope had been living in Cebu for 15 years and had been served with a deportation order late last year. The news outlet reported that Pope had not been deported before the shooting as he still had pending cases in the courts.
Tuesday's shooting came after several recent killings in the country that prompted calls for a tighter gun control.
— With files from The Canadian Press.Suggest a correction