BRAMPTON, Ont. -- A police officer was fulfilling his duty when he gunned down a man who shot him point-blank in the torso and opened fire at a busy Toronto-area courthouse, Ontario's police watchdog ruled Friday.

The officer was on security duty at the Brampton courthouse on March 28 when Charnjit Singh Bassi walked in, pulled a 9mm pistol from his jacket and shot him, the Special Investigations Unit said in a statement.

The officer is not named in the release but the SIU has previously identified him as 53-year-old Const. Mike Klarenbeek.

"He had every reason to believe his life and the lives of those around him were endangered, and that he could not otherwise meet that danger than by shooting at Mr. Bassi," SIU director Tony Loparco said.

"Despite being shot in the torso and suffering a grievous wound, (Klarenbeek) was able to maintain his composure, right himself and return gunfire before collapsing from his injuries," he said.

Another officer who exchanged gunfire with Bassi and hit him in the legs was also justified, Loparco said, noting the law allows officers to use force in self-defence.

"He had just seen Mr. Bassi attempt to kill the subject officer and was the last line of defence before Mr. Bassi made it further into the courthouse with a loaded firearm," he said.

Bassi, 45, was pronounced dead at the scene.

Klarenbeek, a 30-year veteran of the Peel police force, spent roughly a week in hospital before being released to recover at home.

There has been no word on a possible motive for the shooting.

The SIU investigates cases involving police where there has been death, serious injury or allegations of sexual assault.