And one more pulled from my research:
In Anglo-American common law, it is a complete defense to a crime that the act was unconscious or involuntary. Cases turning on this principle normally involve things like purported somnambulism, altered states, or other physical causes for acting without volition. I am not aware of any case in which the defense asserted that a supernatural entity had actually possessed a person, removing his or her faculties, however.
A person's culpability can also be mitigated by a defense of insanity — which traditionally means that at the time of the act the defendant was incapable of understanding the nature of his or her actions, such that he or she could not appreciate that they were wrong. It is quite common for cases in which an insanity defense is presented to turn on facts in which the defendant asserts that he or she heard the voice of god or the devil, or was compelled to act by the devil, or was fighting against the devil, or was in some other way possessed by some divine entity.
In general, if the factfinding indicates that the defendant truly believed the devil was possessing him, this suffices to show that the defendant cannot understand his actions, and the defense of insanity applies.
See, e.g., State v. Brown, 5 Ohio St. 3d 133 (1983).
But see
State v. Yates, in which the defendant's first jury evidently believed expert testimony that because it was
the devil that the defendant heard telling her to murder that she could understand that the act was wrong.
171 S.W.3d 215 (Tex. 2005) ("[The State's expert] reasoned that because appellant indicated that her thoughts were coming from Satan, she must have known they were wrong....").
[Edit] I should clarify that the two cases I cite do actually involve slightly different formulations of the insanity rule, but that even among states that use the rule in the second case, the apparent result in
Yates is an outlier.