A Toronto police officer has been cleared of criminal charges in a fatal shooting that occurred in the city's west end nearly three years ago.

Const. David Cavanagh was originally charged with manslaughter in the death of Eric Osawe, a Toronto man, who was shot during a police search on Sept. 29, 2010.

si-eric-osawe-02193705

Eric Osawe, 26 at the time of his death, is shown in a family handout photo. (Canadian Press)

The charge was subsequently upgraded to second-degree murder in 2012.

Earlier this year, a judge at a preliminary inquiry decided there wasn't enough evidence to commit Cavanagh to trial on the charge. The case was then dismissed.

The Crown appealed that judge's decision, seeking to send Cavanagh to trial on the manslaughter charge he originally faced.

But Ontario Superior Court Judge Michael Quiqley dismissed that appeal on Thursday, ruling that Cavanagh’s weapon accidentally went off during a struggle with Osawe.

Cavanagh had been part of an Emergency Task Force that entered Osawe's apartment with a search warrant for cocaine and a handgun.

The court found that Osawe struggled with several officers as they tried to arrest him the night he died. While Osawe was being subdued and handcuffed on the ground, Cavanagh's MP5 submachine gun discharged.

Quiqley found that the shooting was "entirely unintentional and indeed totally accidental."

"Mr. Osawe's death resulted from a tragic but accidental confluence of circumstances that occurred in a high-pressure and high-risk situation within seconds of the police officers entering his apartment," Quigley wrote in his decision.

Quigley agreed with Crown prosecutors that Cavanagh may have let go of his gun — which was connected to the front of his vest by a sling attached to both shoulders — during the struggle with Osawe. The gun may have got caught on another item on his vest, causing it to fire.

But Quigley wrote that letting go of a gun while trying to subdue a suspect does not go against police policies.

With files from The Canadian Press