An ex post facto law (corrupted from Latin: ex postfacto, lit. 'out of the aftermath') is a law that retroactively changes the legal consequences (or status) of actions that were committed, or relationships that existed, before the enactment of the law. In criminal law, it may criminalize actions that were legal when committed; it may aggravate a crime by bringing it into a more severe category than it was in when it was committed; it may change the punishment prescribed for a crime, as by adding new penalties or extending sentences; or it may alter the rules of evidence in order to make conviction for a crime likelier than it would have been when the deed was committed.
Conversely, a form of ex post facto law commonly called an amnesty law may decriminalize certain acts. (Alternatively, rather than redefining the relevant acts as non-criminal, it may simply prohibit prosecution; or it may enact that there is to be no punishment, but leave the underlying conviction technically unaltered.) A pardon has a similar effect, in a specific case instead of a class of cases (though a pardon more often leaves the conviction itself – the finding of guilt – unaltered, and occasionally pardons are refused for this reason).
Other legal changes may alleviate possible punishments (for example by replacing the death sentence with lifelong imprisonment) retroactively. Such legal changes are also known by the Latin term in mitius.
Some common-law jurisdictions do not permit retroactive criminal legislation, though new precedent generally applies to events that occurred before the judicial decision. Ex post facto laws are expressly forbidden by the United States Constitution in Article 1, Section 9, Clause 3 (with respect to federal laws) and Article 1, Section 10 (with respect to state laws). In some nations that follow the Westminster system of government, such as the United Kingdom, ex post facto laws are technically possible, because the doctrine of parliamentary supremacy allows Parliament to pass any law it wishes. In a nation with an entrenched bill of rights or a written constitution, ex post facto legislation may be prohibited.
While American jurisdictions generally prohibit ex post facto laws, European countries apply the principle of lex mitior ("the milder law"). It provides that, if the law has changed after an offense was committed, the version of the law that applies is the one that is more advantageous for the accused. This means that ex post facto laws apply in European jurisdictions to the extent that they are the milder law.