The writ of habeas corpus is a court order that requires the government or another custodian to bring a detained person before a judge and justify the legality of that detention. Its core purpose is to protect against unlawful imprisonment; it does not decide guilt or innocence, only whether the detention itself is lawful.law.cornell+2

Meaning and purpose

“Habeas corpus” is Latin for “you have the body,” a phrase reflecting the old idea that the court can demand the physical presence of the detained person. In practice, it is one of the main safeguards against arbitrary arrest and imprisonment, because it forces the detaining authority to show legal grounds for custody. If the government cannot justify the detention, the court can order release.brennancenter+1

How it works

A person in custody files a petition asking a court to review the legality of the detention. The court then orders the custodian to explain why the person is being held. If the judge finds that the detention lacks a lawful basis, the person must be freed.uscourts+4

Where it is used

Habeas corpus is most often used by prisoners challenging convictions or sentences, but it can also apply in immigration detention, military detention, extradition disputes, bail issues, and other situations involving custody. It is available to citizens and noncitizens alike in the United States. In criminal cases, it is often used after other appeals are exhausted.usmarshals+3

Constitutional importance

In the United States, habeas corpus is so important that the Constitution protects it, allowing suspension only in rare cases of rebellion or invasion when public safety requires it. That makes it a fundamental check on government power and a cornerstone of due process.americanimmigrationcouncil+1

If you want, I can also explain its history in English law, its U.S. constitutional role, or the difference between habeas corpus and an appeal.