Many states and the federal courts recognize defenses to criminal charges in limited circumstances when the defendant was under duress or committed the criminal offense out of necessity to avoid death or serious bodily injury. The definitions for these affirmative defenses vary from state to state and in the federal courts, with some jurisdictions treating them as the same defense, and others making the distinction that duress applies when a defendant committed the crime because someone forced them to do it, and necessity applies when the defendant was confronted with bad alternatives in an emergency situation and chose the best alternative.
The elements of the defense of duress or necessity are that (1) the defendant was facing an unlawful and imminent threat sufficient to create a reasonable apprehension of death or serious bodily injury; (2) the defendant had not recklessly or negligently placed himself in a situation where he would likely be forced to commit a criminal act; (3) the defendant had no reasonable, legal alternative to violating the law; and (4) the defendant could have reasonably believed that the commission of the criminal act would avoid the threatened harm.
Duress and necessity defenses to criminal charges may be located in a state’s court opinions or cases (common law) or in its statutes—usually in the penal or criminal code. Many states have pattern or form jury charges (questions and instructions) and include a question that may be given to the jury to determine whether the defendant’s conduct is excused by the defense of duress or necessity.
In Texas, both duress and necessity are recognized as affirmative defenses to criminal charges under certain circumstances. According to the Texas Penal Code, the defense of duress (Section 8.05) can be invoked when an individual commits an offense because they were compelled to do so by threat of imminent death or serious bodily injury to themselves or another. The necessity defense (Section 9.22), on the other hand, applies when the defendant argues that their conduct was immediately necessary to avoid imminent harm, and that the harm sought to be avoided by the criminal act was greater than the harm resulting from the act itself. The elements required for these defenses generally align with the four elements you've described: facing an imminent threat, not having placed oneself in that situation through recklessness or negligence, lacking a reasonable legal alternative, and reasonably believing that the criminal act would prevent the threatened harm. These defenses are not absolute and cannot be used in all situations; for example, they are not available for certain crimes. Additionally, Texas does provide pattern jury charges to guide jurors in determining whether a defendant's conduct may be excused by duress or necessity.