Habeas corpus refers to the right of a private citizen to challenge their government to present a reason for his criminal or civil detention. This right was first secured by British citizens against their King with the signing of the Magna Carta in 1215, a document upon which all Western democracy is based, and upon which the Founding Fathers of the United States of America heavily relied.
Specifically, "habeas corpus" is the name of a writ with the object of having a person brought before a court. In Latin, the phrase translates roughly as "[we order that] you produce the body".
Explained another way, habeas corpus is Latin for "you have the body." A writ of habeas corpus generally is a judicial order forcing law enforcement authorities to produce a prisoner they are holding, and to justify the prisoner's continued confinement. Federal judges receive petitions for a writ of habeas corpus from state prison inmates who say their state prosecutions violated federally protected rights in some way.
The right to habeas corpus is phrased as a writ, making reference to the arcane system of writs by which legal claims were adjudicated prior to the 1900s (e.g., the "writ of replevin," or "writ of mandamus"). Thus, the right is referred to as "the writ of habeas corpus," or, "the Great Writ."
The right of habeas corpus is so fundamental that the original United States Constitution itself -- prior to the Bill of Rights -- expressly guarantees it: the "privilege of the Writ of Habeas Corpus shall not be suspended, unless when in Cases of Rebellion or Invasion the public Safety may require it," in Article I, Section 9.
In the United States, a detainee may request a writ of Habeas Corpus review with any court that has jurisdiction. If accepted by the court, the judge issues a writ of Habeas Corpus ordering the individual with custody of the detainee to produce the detainee for a hearing. During the hearing, the judge reviews the lawfulness of the detention, and if found unlawful, orders the detainee released. If, before the hearing, the custodian refuses to produce the body, it is at risk of being found in contempt of court, with potential consequences leading up to and including detention for the custodian until the body is produced.
Former United States Attorney General Alberto Gonzales argued that there is no expressed grant of habeas corpus in the Constitution. Currently, U.S. law states that the privilege may be withheld if the defendant is declared as an "enemy combatant," though recently the Supreme Court held this was not enforceable.