The insanity defense, also known as the mental disorder defense, is an affirmative defense by excuse in a criminal case, arguing that the defendant is not responsible for their actions due to a psychiatric disease at the time of the criminal act. This is contrasted with an excuse of provocation, in which the defendant is responsible, but the responsibility is lessened due to a temporary mental state. It is also contrasted with the justification of self defense or with the mitigation of imperfect self-defense. The insanity defense is also contrasted with a finding that a defendant cannot stand trial in a criminal case because a mental disease prevents them from effectively assisting counsel, from a civil finding in trusts and estates where a will is nullified because it was made when a mental disorder prevented a testator from recognizing the natural objects of their bounty, and from involuntary civil commitment to a mental institution, when anyone is found to be gravely disabled or to be a danger to themself or to others.
Exemption from full criminal punishment on such grounds dates back to at least the Code of Hammurabi. Legal definitions of insanity or mental disorder are varied, and include the M'Naghten Rule, the Durham rule, the 1953 British Royal Commission on Capital Punishment report, the ALI rule (American Legal Institute Model Penal Code rule), and other provisions, often relating to a lack of mens rea ("guilty mind"). In the criminal laws of Australia and Canada, statutory legislation enshrines the M'Naghten Rules, with the terms defense of mental disorder, defense of mental illness or not criminally responsible by reason of mental disorder employed. Being incapable of distinguishing right from wrong is one basis for being found to be legally insane as a criminal defense. It originated in the M'Naghten Rule, and has been reinterpreted and modernized through more recent cases, such as People v. Serravo.
In the United Kingdom, Ireland, and the United States, use of the defense is rare.