(a) General rule.–A person who timely offers a defense of insanity in accordance with the Rules of Criminal Procedure may be found “guilty but mentally ill” at trial if the trier of facts finds, beyond a reasonable doubt, that the person is guilty of an offense, was mentally ill at the time of the commission of the offense and was not legally insane at the time of the commission of the offense.
(b) Plea of guilty but mentally ill.–A person who waives his right to trial may plead guilty but mentally ill. No plea of guilty but mentally ill may be accepted by the trial judge until he has examined all reports prepared pursuant to the Rules of Criminal Procedure, has held a hearing on the sole issue of the defendant’s mental illness at which either party may present evidence and is satisfied that the defendant was mentally ill at the time of the offense to which the plea is entered. If the trial judge refuses to accept a plea of guilty but mentally ill, the defendant shall be permitted to withdraw his plea. A defendant whose plea is not accepted by the court shall be entitled to a jury trial, except that if a defendant subsequently waives his right to a jury trial, the judge who presided at the hearing on mental illness shall not preside at the trial.
(1) “Mentally ill.” One who as a result of mental disease or defect, lacks substantial capacity either to appreciate the wrongfulness of his conduct or to conform his conduct to the requirements of the law.
(2) “Legal insanity.” At the time of the commission of the act, the defendant was laboring under such a defect of reason, from disease of the mind, as not to know the nature and quality of the act he was doing or, if he did know it, that he did not know he was doing what was wrong.