A New York Police Department sergeant has been found not guilty in the fatal shooting of a bat-wielding mentally ill woman, a judge ruled Thursday morning.

Bronx Supreme Court Justice Robert Neary said he found Sgt. Hugh Barry not guilty of all charges — including murder — in the Oct. 2016 shooting of 66-year-old Deborah Danner, reports the New York Post.

Photo: NYPD/Facebook

Photo: NYPD/Facebook

"Clearly this case involved a terrible tragedy and emotions on both sites are elevated," Neary said, before declaring that Barry was found not guilty of second-degree murder, first and second degree manslaughter, and criminally negligent homicide.

Barry testified during the two-week proceeding that he shot the schizophrenic woman twice because he feared for his life.

"I just see the bat swinging, and that's when I fired,'' the 32-year-old said from the stand Tuesday. "I'm looking at this bat that can crack me in the head and kill me."

Defense lawyer Andrew Quinn argued Wednesday that Barry was imminently threatened when Danner took a step in his direction holding the bat.

A nine-year veteran of the 43rd Precinct, Barry could have faced up to life in prison if he had been convicted on the murder charge.

"There is no victory here today," Patrolmen's Benevolent Association President Patrick J. Lynch said in a statement, "only relief that justice has been served and a good man who was doing a difficult and dangerous job has been exonerated."