Habeas corpus (/ˈheɪbiəs ˈkɔːrpəs/) is a recourse in law challenging the reasons or conditions of a person's confinement under color of law. A petition for habeas corpus is filed with a court that has jurisdiction over the custodian, and if granted, a writ is issued directing the custodian to bring the confined person before the court for examination into those reasons or conditions. The Suspension Clause of the United States Constitution specifically included the English common law procedure in Article One, Section 9, clause 2, which demands that "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."
United States law affords persons the right to petition the federal courts for a writ of habeas corpus. Individual states also afford persons the ability to petition their own state court systems for habeas corpus pursuant to their respective constitutions and laws when held or sentenced by state authorities.
Federal habeas review did not extend to those in state custody until almost a century after the nation's founding. During the Civil War and Reconstruction, as later during the War on Terrorism, the right to petition for a writ of habeas corpus was substantially curtailed for persons accused of engaging in certain conduct. In reaction to the former, and to ensure state courts enforced federal law, a Reconstruction Act for the first time extended the right of federal court habeas review to those in the custody of state courts (prisons and jails), expanding the writ essentially to all imprisoned on American soil. The federal habeas statute that resulted, with substantial amendments, is now at 28 U.S.C. § 2241. For many decades, the great majority of habeas petitions reviewed in federal court have been filed by those imprisoned in federal prisons by state courts for state crimes (e.g., murder, rape, robbery, etc.), since in the American system, crime has historically been a matter of state law.