Ex turpi causa non oritur actio

 (Latin "from a dishonorable cause an action does not arise") is a legal doctrine which states that a plaintiff will be unable to pursue legal relief and damages if it arises in connection with their own tortious act. Particularly relevant in the law of contract, tort and trusts, ' is also known as the illegality defence"', since a defendant may plead that even though, for instance, he broke a contract, conducted himself negligently or broke an equitable duty, nevertheless a claimant by reason of his own illegality cannot sue. The UK Supreme Court provided a thorough reconsideration of the doctrine in 2016 in "Patel v Mirza". 
Illegality in English Law.
Development.
In the early case of "Holman v Johnson" Lord Mansfield CJ set out the rationale for the illegality doctrine.
Tort.
In the law of tort, the principle would prevent a criminal from bringing a claim against (for example) a fellow criminal. In "National Coal Board v England", Lord Asquith said,
In "Hewison v Meridian Shipping Services Pte Ltd", an employee who had obtained his position by concealing his epilepsy was held not to be entitled to claim compensation for future loss of earnings as a result of his employer's negligence, since his deception (resulting in a pecuniary advantage contrary to the Theft Act 1968) would prevent him from obtaining similar employment in future.
It is not absolute in effect. For example, in "Revill v Newbery" an elderly allotment holder was sleeping in his shed with a shotgun, to deter burglars. On hearing the plaintiff trying to break in, he shot his gun through a hole in the shed, injuring the plaintiff. At first instance, the judge awarded damages on the basis that the defendant had used violence in excess of the reasonable limits allowed by lawful self-defence and was negligent to the standard of care expected of a reasonable man who found himself in such a situation. On appeal the defendant raised the defence of "", but the Court of Appeal held that while public interest required that someone should not benefit from his illegal conduct, different considerations applied in cases arising in tort as opposed to those in a property or contract context. Old common law authorities and the Law Commission report (Liability for Damage or Injury to Trespassers) acknowledged the existence of some duty towards trespassers and the defendant could not rely on the doctrine to relieve himself of liability.
The precise scope of the doctrine is not certain. In some cases, it seems that the illegality prevents a duty of care arising in the first place. For example, in "Ashton v Turner" the defendant injured the plaintiff by crashing the car they sat in together in the course of fleeing the scene of a burglary they had committed together. Ewbank J held that the court may not recognise a duty of care in such cases as a matter of public policy. Similarly, in "Pitts v Hunt" the Court of Appeal rationalised this approach, saying that it was impossible to decide the appropriate standard of care in cases where the parties were involved in illegality.
If the illegality vanishes as a result of legislative action (for example a law making a tortious act not tortious) or some subsequent court case where the law is declared invalid, the tort action will stand. In the case of "Martin v. Ziherl", the two parties were girlfriend and boyfriend until Martin discovered Ziherl had given her herpes. Martin sued Ziherl for damages in Virginia Circuit Court, and Ziherl argued that because of the case of "Zysk v. Zysk" since having sex with someone they were not married to was technically the crime of fornication, Martin could not sue Ziherl because she got herpes as a result of the illegal act. Martin argued the act was unconstitutional. The court agreed with Ziherl and against Martin. Martin appealed, and the Supreme Court of Virginia reversed, agreeing with Martin's argument that because the United States Supreme Court had decided in "Lawrence v. Texas" that noncommercial, private intimacy was a protected right, the law-making fornication a crime was unconstitutional, thus Martin could now sue since the law that made having sex with someone they were not married to was struck down as void.
Trusts.
In other cases, the courts view "" as a defence where otherwise a claim would lie, again on grounds of public policy. In "Tinsley v Milligan" (overruled by Tinsley v Milligan) Nicholls LJ in the Court of Appeal spoke of the court having to "weigh or balance the adverse consequences of granting relief against the adverse consequences of refusing relief". The plaintiff was ultimately successful in "Tinsley v Milligan" in the House of Lords, which allowed the claim on the grounds that the plaintiff did not need to rely on the illegality.
Contract.
The doctrine in the aspect of contract essentially does the same thing as one of the vitiating contractual elements known as 'illegality'. Here contractual remedies cannot be enforced by a court on a defendant if it is manifest that the subject matter of the contract is either directly or by implication, contrary to public policy or in contradiction with any existing law or custom. A somewhat related concept in the law of contracts is the equitable defense of unclean hands.
Major reconsideration of the doctrine by the UK Supreme Court.
In 2016 the UK Supreme Court provided a major reconsideration of this doctrine, in "Patel v Mirza", overruling the test in "Tinsley v Milligan" and replacing it with a new set of principles. The changes were described as 'revolutionary' by a judge on the case, Lord Sumption (at [261] in the judgment).