TORONTO -- A Toronto police officer who had been charged with second-degree murder after he shot and killed a man during a raid three years ago has been cleared of criminal charges after a judge found it was "totally accidental."

Const. David Cavanagh was part of an Emergency Task Force team that burst into Eric Osawe's west-end Toronto apartment on Sept. 29, 2010, on a search warrant for cocaine and a handgun.

Osawe, 26, was lying on the bed and when he didn't immediately get to the floor as ordered, Cavanagh took him to the ground, Ontario Superior Court Judge Michael Quiqley found Thursday.

Osawe struggled with the several officers as Cavanagh turned him onto his chest, trying to subdue and handcuff him, Cavanagh's MP5 submachine gun went off, Quigley wrote in his decision.

Quigley dismissed a Crown appeal of an earlier court decision that also ruled the shooting was accidental.

After the gun fired, Cavanagh immediately moved away with his arms outstretched and a panicked look on his face, the judge found.

"He called, 'Medic,' but it quickly became clear that Mr. Osawe was beyond help," Quigley wrote. "The single bullet had severed Mr. Osawe's spine and paralyzed him."

Osawe died within 10 to 15 seconds, Quigley found.

Cavanagh was originally charged with manslaughter but it was later upgraded to second-degree murder. After a preliminary inquiry earlier this year, a judge decided there was wasn't enough evidence to commit Cavanagh to trial and dismissed the case.

The Crown appealed, asking Quigley to overturn that decision and instead send Cavanagh to trial on the original manslaughter charge.

But he declined, finding 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.

The Crown had argued two scenarios. Cavanagh may have let go of his gun, which was connected to the front of his vest by a sling attached to both shoulders, which meant it pointed downward and discharged after getting caught on another item on Cavanagh's vest, the Crown said.

That is likely what happened, Quigley found, but letting go of the gun with both hands to help subdue a suspect doesn't go against police policies, he said.

In the alternative, Cavanagh may have unintentionally pulled the trigger, the Crown argued.

But there was no evidence his finger was ever on the trigger, Quigley said.

"Cavanagh acted consistently and in full compliance with his training at all times," Quigley wrote.

"If those policies are found to be unsafe or wanting, that may give rise to a reprimand from other sources on another day, perhaps following an inquest or other inquiry, or that may give rise to changes in operating policies."