> It is a defense to any offense that the accused was acting pursuant to orders unless the accused knew the orders to be unlawful or a person of ordinary sense and understanding would have known the orders to be unlawful.
So for those non-military reading, while it's almost always a bad idea to try to sea-lawyer your way out (though some court challenges have worked), you also are expected to use "ordinary sense and understanding" to reject orders like "go massacre those clearly unarmed noncombatants." But if it's not as cartoonishly obvious as that, there's a good chance you will have to defend your actions at a court-martial, and the legality of the order will be down to the interpretation of the presiding military judge and appellate courts.
- That a member of the armed forces issued a certain lawful order;
- That the accused had knowledge of the order; and
- That the accused had a duty to obey the order; and
- That the accused failed to obey the order.
If the order is deemed unlawful by the military judge or appellate court, the case must be dismissed, because the Government has failed to allege an offense.
It's less a legal provision than a consequence of humans being the interface of the law. So while there is, in theory, a duty to disobey, there is also a presumption of lawfulness of orders [1][2].
[1] https://ucmjdefense.com/resources/military-offenses/the-lawf...
[2] https://warontherocks.com/2017/07/when-can-a-soldier-disobey...