Habeas corpus (/ˈheɪbiəs ˈkɔːrpəs/; Medieval Latin meaning literally "You may have the body") is a recourse in law whereby a person can report an unlawful detention or imprisonment before a court, usually through a prison official.
The writ of habeas corpus is known as "the great and efficacious writ in all manner of illegal confinement", being a remedy available to the meanest against the mightiest. It is a summons with the force of a court order; it is addressed to the custodian (a prison official for example) and demands that a prisoner be taken before the court, and that the custodian present proof of authority, allowing the court to determine whether the custodian has lawful authority to detain the prisoner. If the custodian is acting beyond his or her authority, then the prisoner must be released. Any prisoner, or another person acting on his or her behalf, may petition the court, or a judge, for a writ of habeas corpus. One reason for the writ to be sought by a person other than the prisoner is that the detainee might be held incommunicado. Most civil law jurisdictions provide a similar remedy for those unlawfully detained, but this is not always called habeas corpus. For example, in some Spanish-speaking nations, the equivalent remedy for unlawful imprisonment is the amparo de libertad ('protection of freedom').
Habeas corpus has certain limitations. Though a writ of right, it is not a writ of course. It is technically only a procedural remedy; it is a guarantee against any detention that is forbidden by law, but it does not necessarily protect other rights, such as the entitlement to a fair trial. So if an imposition such as internment without trial is permitted by the law, then habeas corpus may not be a useful remedy. In some countries, the writ has been temporarily or permanently suspended under the pretext of war or state of emergency.