A Dakota County judge Friday found a murder defendant not guilty by reason of mental illness in the fatally shooting of another man last summer at a Burnsville hotel.

Judge Tim Wermager said that Ricky E. Ramirez, 25, of Houston, Texas, had proven in court that a mental illness prevented him from understanding right from wrong when he killed 37-year-old Sheldon J. Williams, of South Carolina.

Wermager acquitted Ramirez of second-degree murder and ordered him to remain jailed in lieu of $1 million bail pending proceedings for civil commitment to a secure facility as mentally ill and dangerous.

Two doctors examined Ramirez and concluded that he was "experiencing paranoia and auditory hallucinations" at the time of the shooting, read Wermager's finding. "He honestly believed that someone was trying to hurt or kill himself or others."

According to the complaint:

Police were notified of gunfire at the Burnsville Inn and Suites in the 1100 block of W. Burnsville Parkway on July 23 and found Ramirez on the second floor with a handgun near his feet.

While being handcuffed, Ramirez directed police to a door, where "they have an AR [rifle], and they have 100 more," the complaint quoted him as saying.

Ramirez then pointed to the body of Williams in the hall. He had been shot in the head and was declared dead at the scene. Hotel security video showed Williams leaving a room and appearing to be unarmed before he was shot six times.