A contract can be perfectly formed and still fail because the law refuses to lend its aid to wrongdoing. This chapter opens with the doctrine itself, its range of consequences and the modern proportionality approach, before examining statutory illegality and the distinction between express and implied prohibition, and the separate question of whether the illegality arises at formation or only in performance. It then turns to common law illegality — contracts to commit crimes, torts or fraud — and how each party's knowledge of an illegal purpose shapes enforcement. The chapter closes with restraint of trade clauses, the legitimate interests that can justify them, severance and the blue pencil test, and how the illegality defence is raised, including the court's power to take the point of its own motion.