FORT LAUDERDALE, Fla. (UPI) — A judge dropped charges against a Florida sheriff’s deputy accused of manslaughter, ruling he was acting in self-defense when he fatally shot a man holding an air rifle.

In a 36-page ruling, Broward Circuit Court Judge Michael Usan wrote that Broward County Sheriff’s Deputy Peter Peraza was justified in using deadly force against Jermaine McBean under the state’s so-called “Stand Your Ground” law.

Wednesday’s dismissal of charges against Peraza will be appealed, a statement from the State Attorney’s Office said. The FBI is also investigating the case, in which Peraza shot McBean in July 2013 after McBean allegedly refused to drop an air rifle he was carrying as he walked through an Oakland Park, Fla., neighborhood.

In six days of hearings in June, prosecutors attempted to demonstrate Peraza was not entitled to immunity from prosecution under the controversial law, and argued Peraza should face a jury.

Usan wrote that McBean was having a “psychotic episode,” ignored police commands to drop the air rifle and pointed it at officers who thought it was a real gun, adding Peraza was “in fear for his life and the lives of others.” In the ruling, the judge questioned the credibility of a witness who challenged police accounts of the incidents; the witness said McBean did not point the gun at officers and did not hear police commands to drop his weapon because he was wearing earbuds.

Usan called McBean, “a good man” with “serious and significant mental-health issues,” for which he had been treated prior to the shooting incident. He added an autopsy revealed McBean had not taken his medication on the day he purchased an air rifle at a pawn shop and walked home with it on his shoulder.

Peraza is the county’s first law enforcement officer to face charges for shooting a civilian while on duty since 1980.

David Schoen, lawyer for the McBean family, said he would proceed with a federal civil rights lawsuit.