Primal Fear

Martin Vail (Richard Gere) is a Chicago defense attorney who loves the public spotlight and does everything he can to get his high-profile clients acquitted on legal technicalities. One day, he sees a news report about the arrest of Aaron Stampler (Edward Norton), a young altar boy from Kentucky with a severe stutter, who is accused of brutally murdering the beloved Archbishop Rushman (Stanley Anderson). Vail jumps at the chance to represent the young man pro bono.
During his meetings at the county jail with Aaron, Vail comes to believe that his client is innocent, much to the chagrin of the prosecutor (and Vail's former lover), Janet Venable (Laura Linney).
As the murder trial begins, Vail discovers that powerful civic leaders, including the corrupt State's attorney John Shaughnessy (John Mahoney), have lost millions of dollars in real estate investments due to a decision by the Archbishop not to develop on certain church lands. The Archbishop received numerous death threats as a result. Vail makes a search of the Archbishop's apartment and finds a videotape of Stampler being forced to perform in a sexual act with another altar boy and a girl named Linda (Azalea Davila). Vail is now in a bind: Introducing this evidence would make Stampler more sympathetic to the jury, but it would also give his client a motive for the murder, which Venable is unable to establish.
When Vail confronts his client and accuses him of having lied, Stampler breaks down crying and suddenly transforms into a new persona: a violent sociopath who calls himself "Roy" who confesses to the murder of the Archbishop and throws Vail against a wall of his jail cell. When this incident is over, Aaron's personality re-emerges and appears to have no recollection of the personality switch. Molly Arrington (Frances McDormand), the psychiatrist examining Aaron, is convinced that he suffers from multiple personality disorder caused by years of abuse at the hands of his father. Vail does not want to hear this, because he knows that he cannot enter an insanity plea during an ongoing trial.
Vail sets up a confrontation in court by dropping hints about the Archbishop's pedophilia, as well as Stampler's multiple personalities. He also has the sex tape delivered to Venable, knowing she will realize who sent it andâsince she is under intense pressure from both Shaughnessy and her boss Bud Yancy (Terry O'Quinn) to deliver a guilty verdictâwill use it as proof of motive.
Vail puts Stampler on the witness stand and gently questions him about the abuse he suffered at the Archbishop's hands. After Venable questions him harshly during cross-examination, Stampler turns into "Roy" in open court and attacks her, threatening to snap her neck if anyone comes near him. He is subdued by courthouse marshals and rushed back to his holding cell. The judge (Alfre Woodard) dismisses the jury in favor of a bench trial and then finds Stampler not guilty by reason of insanity, remanding him to a maximum security mental hospital. Venable is fired for losing the case and allowing the Archbishop's crimes, which both the Catholic Church and the city council had been trying to hide for the past ten years, to come to public light.
Vail visits Stampler in his cell to tell him of the dismissal. Stampler says he recalls nothing of what happened in the courtroom, having again "lost time." Just as Vail is leaving, Stampler asks him to "tell Miss Venable I hope her neck is okay," which he could not have been able to remember if he had "lost time." When Vail confronts him, Stampler reveals that he had faked multiple personality disorder. No longer stuttering, he brags about having murdered Archbishop Rushman, as well as Linda. He additionally reveals that "Aaron" was the fabricated personality, implying that Roy is his true identity. A stunned and disillusioned Vail walks away as Stampler taunts him from his cell.

Question: Why is Stampler found not guilty?
Answer: Reason of insanity