A St. Paul man who fatally shot his girlfriend last fall in the apartment they shared has been found not guilty because he was mentally ill at the time.

Andre A. Duprey, 30, was acquitted Friday of second-degree murder by Ramsey County District Judge Joy D. Bartscher.

Duprey, jailed since his arrest soon after he shot 28-year-old Phanny Phay, awaits transfer to the state psychiatric hospital in St. Peter for treatment pending completion of civil commitment proceedings.

Bartscher wrote in her verdict that Duprey suffered from bipolar disorder “with psychotic symptoms” at the time of the killing and believed Phay was possessed by demons.

She added that because Duprey “was unable to know the nature of the act … or that it was wrong, [he] is not guilty … by reason of mental illness.”

Her ruling included a psychiatric evaluation during which Duprey recounted calling police several days before shooting and stabbing Phay because he believed people were trying to rob and kill him.

On the day of Phay’s death, Duprey recalled during the evaluation, he believed his girlfriend “was a demon or under the control of a demon,” the judge’s ruling noted.

Police were called to the apartment in the 900 block of St. Paul Avenue about 2 a.m. on Nov. 10 and spotted a handgun in the living room and Duprey in the bathroom entry holding a knife.

“He was chanting, ‘demon, demon,’ ” the criminal complaint said. Police subdued him with a stun gun, blows from a baton and beanbag rounds.

Phay was facedown on the bedroom floor with a large head wound. A bloody shotgun was on the bed. She also had dozens of knife wounds.

Duprey allegedly told police he did not remember what occurred and that he had no difficulties with his girlfriend.

Phay graduated from Bloomington Kennedy High School and earned a full scholarship to attend the University of Minnesota. She graduated in 2013 and intended to become a doctor and focus on juvenile health care.

“Her kindness truly had no boundaries,” her online obituary read. “Not only did she volunteer at Fairview Hospital but overseas in India too. … She devoted much of her time and energy as a caregiver to family members, including her mother.”

Duprey met Phay at the University of Minnesota, where he graduated with a degree in political science. The Army veteran also had been a legislative aide at the State Capitol.