An ex post facto law is a legislative act that retroactively changes the legal consequences of actions that were committed before the law was enacted. This type of law makes an action illegal or increases the penalties for a crime after it has already occurred, violating principles of fairness and justice by punishing individuals for actions that were not illegal at the time they were committed.