The NYPD sergeant on trial for the fatal shooting of a bat-wielding Bronx woman has been found not guilty in the woman’s death, 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.

“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 or criminally negligent homicide.

“In this case the prosecution has an additional burden beyond reasonable doubt that the defendant is not justified,” she continued. “In both regards the prosecution’s evidence has failed to meet the burden of proof.”

Barry looked stoic and emotionless as the verdict was read. Jennifer Danner, Deborah’s sister, raised her eyebrows slightly. At one point, she appeared tearful as she rested her head on another woman’s shoulder.

Defense lawyer Andrew Quinn said that Barry is “overwhelmed.”

“He has been through a difficult time,” Quinn said. “We have always felt confident we would win, but you never know until you see the evidence.”

“I thought he was very honest,” he added. “I thought he explained in specific detail exactly what happened inside that room and described it as it was. It could’ve ended very, very differently. And I think that’s why he was able to convey this to the judge.”

Barry, who was escorted by police the whole time, was nowhere to be found after the verdict was read.

He was on his way to church “to catch a Mass,” Sergeants Benevolent Association President Ed Mullins said.

The Sergeants Benevolent Association received the news with “much joy and relief,” according to a statement posted on Twitter.

“Sgt. Barry committed no crime and was justified in his actions,” the statement said. “I commend Judge Neary for recognizing that and acquitting Sgt. Barry of these horrendous charges.”

But Bronx District Attorney Darcel D. Clark had a more somber reaction.

“The judge has issued his verdict in this case,” she said in a statement. “We are disappointed but we accept his decision. However, I believe the death of Deborah Danner illustrates the larger issue of how we need changes in the way we address people with mental health issues.”

“There must be serious reforms to improve access to treatment so the situation does not rise to a crisis,” she added. “Mental health professionals should be part of the response to emotionally disturbed persons. I hope that measures will be taken to prevent another tragedy such as this.”

Barry, who opted for a non-jury trial, testified during the two-week proceeding that he fired two bullets into the schizophrenic woman–using his service weapon, not a taser–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.”

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

“If she hadn’t taken that step, we wouldn’t be having a trial. We wouldn’t be having a funeral,” the defense attorney said.

But prosecutors insisted during the proceedings that Barry ignored his training when he walked into the mentally ill woman’s bedroom — causing the already angry and agitated Danner to have become even more aggravated.

“[Barry] failed to fulfilled his duties as a patrol supervisor,” Assistant DA Wanda Perez-Maldonado argued during her closings. “He failed to make use of the resources available to him.”

“He created to the situation….that led to her death,” Maldonado added.

The deadly incident began when the 31-year-old sergeant and others arrived at Danner’s apartment after a neighbor reported a screaming resident.

Barry peered into the woman’s bedroom, where he spotted her sitting “on her bed furiously snapping a pair of green-handled metal scissors,” according to court papers.

He claims he asked her to put the scissors down, but she brandished them in his direction, and spat, “I’m not f–king coming out!”

She eventually dropped the scissors, but then pulled a baseball bat from between her bed sheets and lunged at Barry–who was also armed with a taser, the papers say.

He fired two shots from his service weapon, hitting her in the torso, and she later died at a nearby hospital.

The shooting prompted street protests and was immediately criticized by police commissioner James O’Neill, who told reporters, “We failed,” and Mayor de Blasio, who called Danner’s death “tragic and unacceptable.”

Mullins sharply criticized both officials — and the ADA — on Thursday, saying that they “play politics.”

“Sgt. Barry should be immediately reinstated,” he declared. “He was wronged all along and it’s up now to the commissioner to make it right. He owes him an apology, the mayor owes him an apology and so does the district attorney.”

Barry’s case marks the first time an on-duty officer has faced murder charges since the notorious police shooting of Amadou Diallo in 1999.

Danner’s family has filed a federal lawsuit against the city.

A nine-year veteran of the 43rd Precinct, Barry could have faced up to life in prison if he was 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.”