Cebu gun factory
The Philippines has imposed a nationwide ban on guns ahead of elections in May (Reuters)

A Canadian man who was prosecuted for illegal possession of firearms pulled out a weapon at his court hearing in the Philippines and shot dead two people before he was shot by police.

John Pope, 65, who was in the dock on charges of illegal possession of firearms, opened fire as the hearing got under way. A prosecutor was injured in the Cebu City courthouse.

Pope, a resident of the city, was in court to answer the firearm charges. He then pulled out a gun and shot a lawyer and the doctor who had filed the case against him.

He fired at the prosecutor in the hallway of the courthouse and shot at police, who returned fire, Cebu police chief Mariano Natuel said.

150-day gun ban

"We are investigating how the suspect managed to bring in the gun," regional police chief Marcelo Garbo told local radio.

"Two people were killed, while two were wounded, including the Canadian."

Local media said Pope was held by police in 2011 for illegal possession of firearms, malicious mischief and grave threats. He said he carried the gun for self-defence.

The doctor who had accused Pope was his neighbour. He told police Pope had a weapon and had threatened him and other residents.

The court shooting was the latest incident in a series of handgun killings in the Philippines, which has led to calls for tighter restrictions.

A 150-day ban on the carrying of guns outside homes was imposed across the country to prevent violence that could break out during the elections in May.

The ban, which suspends all permits to carry firearms in public areas, will end on 12 June. The only people it does not apply to are top officials, on-duty troops and police.

People who violate the ban face up to six years in jail.