Habeas corpus is a court proceeding that tests whether the government has a legal right to keep someone locked up. A judge reviews the detention and can order release or a new proceeding if it violates the Constitution or federal law. People use it after a state or federal conviction, and also to challenge some immigration detention. For people convicted in state or federal court, federal petitions run on strict statutory rules, including a one-year deadline.
Where does the right to habeas corpus come from?
The Constitution protects it by name. Article I, Section 9 says 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, as the National Archives transcript of the Constitution shows. That clause is the Suspension Clause. It does not spell out how a petition works. Congress filled that in with statutes, and those statutes control a real case today.
The word "writ" just means a written court order. A writ of habeas corpus is an order directed at whoever holds a person, usually a prison warden or a federal immigration official, telling that official to justify the detention. Federal law gives that power to the Supreme Court, the justices, the district courts and the circuit judges within their jurisdictions (28 U.S.C. 2241(a)). Most petitions start in a federal district court, which is the federal trial-level court.
What does a habeas court actually decide?
It decides a narrow question. For a state prisoner, federal law lets a court hear an application only on the ground that the person "is in custody in violation of the Constitution or laws or treaties of the United States" (28 U.S.C. 2254(a)). A habeas case is not a second trial. The judge is not asking whether the jury got the verdict right. The question is whether something went wrong in the process that the Constitution or a federal law forbids.
Typical claims include a lawyer whose performance fell so low that it broke the Sixth Amendment, evidence the prosecution hid, a confession taken in violation of constitutional rules, or a plea that was not truly voluntary. Our guide to ineffective assistance of counsel covers the most common of these. A mistake of state law alone, such as a misread state evidence rule, generally does not qualify, because the federal statute is tied to federal rights.
Habeas also has a place beside the ordinary appeal. A direct appeal comes first and covers errors in the trial record. Habeas and its state equivalents often reach things the trial record cannot show, like a lawyer's private failures. For the full picture of what comes after a conviction, read what post-conviction relief is.
Which federal habeas law applies to your case?
Three federal statutes do most of the work, and the one that fits depends on who is holding you and why. Pick the wrong one and a petition can be dismissed on the label alone.
Statute
Who uses it
Where it is filed
28 U.S.C. 2254
A person in custody under a state court judgment
Federal district court, after state remedies are used up
28 U.S.C. 2255
A federal prisoner attacking the sentence imposed by a federal court
The same federal court that imposed the sentence
28 U.S.C. 2241
Others held under federal authority, including many immigration detainees
A federal district court with jurisdiction over the case (2241(a))
Section 2255 says a prisoner "in custody under sentence of a court established by Act of Congress" who claims the sentence violated the Constitution or federal law may "move the court which imposed the sentence to vacate, set aside or correct the sentence." That is a motion, not a separate lawsuit. The same statute limits habeas applications by prisoners who can use that motion, unless the motion remedy "is inadequate or ineffective to test the legality of his detention" (28 U.S.C. 2255(e)).
Section 2241 is the broadest. It reaches a person held "under or by color of the authority of the United States" and a person held "in violation of the Constitution or laws or treaties of the United States" (28 U.S.C. 2241(c)). If a state has more than one federal judicial district, 2241(d) lets a state prisoner file in the district where he is held or the district where the state court sat. If you are unsure which route fits a federal detention, that question alone is worth a lawyer's time.
A state conviction and a federal conviction can sound alike but travel different paths. If you are not sure which system prosecuted you, see federal versus state criminal charges.
What does exhaustion of state remedies mean?
Before a federal judge hears a state prisoner's claim, the state courts get the first chance to fix it. A federal habeas application for a state prisoner "shall not be granted" unless the applicant has exhausted the remedies available in state court, or there is no state process, or that process cannot protect the applicant's rights (28 U.S.C. 2254(b)(1)). Exhaustion is the legal word for using up those state options.
The statute also says you have not exhausted a remedy if you still have a right under state law to raise the question "by any available procedure" (28 U.S.C. 2254(c)). In plain terms, you must usually take each claim through the state's direct appeal and its post-conviction process, up to the state's highest court that hears such claims. Which court that is, and what the state calls its own version of habeas relief, varies.. Some states say post-conviction petition, some say state habeas, others use older names. The steps and time limits for those state proceedings differ from state to state, so check your own state's rules before counting on any deadline you have heard about.
The details of exhaustion are where many petitions die. Federal courts generally expect each claim to have been presented to the state courts as a federal claim, not just described as unfair. If a claim was left out of the state case, a federal court may refuse to consider it later.
How long do you have to file a habeas petition?
For a state prisoner, the federal statute sets a one-year limit: "A 1-year period of limitation shall apply to an application for a writ of habeas corpus by a person in custody pursuant to the judgment of a State court" (28 U.S.C. 2244(d)(1)). A federal prisoner filing a 2255 motion has a one-year period too (28 U.S.C. 2255(f)). These are the only filing time limits this page states.. State post-conviction deadlines differ by state and are not covered here.
The one-year clock does not always start on the same day..... It runs from the latest of four dates for a state prisoner:
The date the judgment became final, by the conclusion of direct review or the end of the time for seeking it.
The date a state-created illegal obstacle to filing was removed, if the state's action stopped you from filing.
The date the Supreme Court first recognized a constitutional right, if the right is newly recognized and has been made retroactive to cases on collateral review.
The date the factual basis for the claim could have been discovered with due diligence.
Federal 2255 motions have the same four triggers, worded for the federal case (28 U.S.C. 2255(f)(1) to (4)).
Most people are on the first one. Final means the direct appeal is finished or the time to seek more review has run out. There is a pause too. Time during which "a properly filed application for State post-conviction or other collateral review" is pending "shall not be counted toward any period of limitation" (28 U.S.C. 2244(d)(2)). The pause only covers days while the state petition is pending. Days that pass before you file it still count, and a state petition that was not properly filed may not stop the clock at all. Counting these days correctly is the single most useful task for a lawyer in a habeas case. Do it in writing, with dates from court records.
Why is it so hard to win a habeas claim?
Because Congress wrote the statute to make federal courts defer to state courts. Under 28 U.S.C. 2254(d), a federal court cannot grant relief on a claim that a state court decided on the merits unless that decision either "was contrary to, or involved an unreasonable application of, clearly established Federal law, as determined by the Supreme Court of the United States," or was "based on an unreasonable determination of the facts in light of the evidence presented in the State court proceeding."
That language is the AEDPA standard, named for the Antiterrorism and Effective Death Penalty Act of 1996. It sets a high bar. It is not enough that the federal judge would have ruled differently. The state decision has to be unreasonable under what the Supreme Court has clearly established, and the statute names the Supreme Court as the source of that law.
Two more rules raise the bar. First, a state court's finding of fact "shall be presumed to be correct," and the applicant has "the burden of rebutting the presumption of correctness by clear and convincing evidence" (28 U.S.C. 2254(e)(1)). Second, a lawyer's poor work during state or federal post-conviction proceedings "shall not be a ground for relief" under 2254 (28 U.S.C. 2254(i)). So a lawyer who botched the state habeas petition does not by that fact alone open a federal claim, though the trial lawyer's work can.
The standard explains why a claim that sounds strong can still lose. A petition that carefully shows the state court applied the wrong Supreme Court rule, or ignored the record, has a much better shot than one that argues the verdict was unfair. If your claim is that new evidence shows the trial itself was unfair, compare it with the options in how to get a new trial.
What are second or successive habeas petitions?
You generally get one federal habeas application per judgment. A second one faces a gatekeeping system. Under 28 U.S.C. 2244(b), a claim in a second or successive 2254 application that was presented in a prior application "shall be dismissed." A new claim "shall be dismissed unless" it meets narrow exciptions set out in that section.
The process also changes where you start. Before a district court can consider a second or successive application, the applicant must "move in the appropriate court of appeals for an order authorizing the district court to consider the application." A three-judge panel decides that motion, the court of appeals may authorize the filing only if there is a prima facie showing that the requirements are met, and the court of appeals is to decide "not later than 30 days after the filing of the motion" (28 U.S.C. 2244(b)(3)). A grant or denial of authorization cannot be appealed and cannot go to the Supreme Court by a petition for certiorari.
Federal prisoners face a parallel rule. A second or successive 2255 motion must be certified by a panel of the court of appeals to contain either newly discovered evidence that, if proven, would show by clear and convincing evidence that no reasonable factfinder would have found the movant guilty, or a new rule of constitutional law, made retroactive by the Supreme Court, that was previously unavailable (28 U.S.C. 2255(h)).
Because you may only get one real shot, a first petation should include every claim you have, supported by the record, and it should be filed on time. Filing quickly and incompletely can cost you claims you cannot get back.
Can you use habeas corpus to challenge immigration detention?
Yes, in some situations. Habeas under 28 U.S.C. 2241 is the usual vehicle for asking a federal court to review immigration detention, because 2241(c)(3) covers a person held in violation of the Constitution or federal law. The relief people usually seek is a bond hearing or release, not a ruling on whether they can stay in the country. The law here is technical, and detention questions have been litigated heavily in recent years, so what applies today needs a current check.
The Supreme Court has set the outer boundaries. In Zadvydas v. Davis (2001), the Court read the detention statute for people with final removal orders to limit detention after the 90-day removal period to "a period reasonably necessary to bring about that alien's removal from the United States." The Court described that holding again in its 2022 decision Johnson v. Arteaga-Martinez, available on the Supreme Court's website.
In Jennings v. Rodriguez (2018), the Court held that three federal detention provisions (8 U.S.C. 1225(b) and 1226(a) and (c)) do not give detained noncitizens the right to periodic bond hearings during their detention (583 U.S. 281, in the official U.S. Reports). The case sent constitutional arguments back to the lower courts. In Arteaga-Martinez, the Court held that the post-removal-period detention provision, 8 U.S.C. 1231(a)(6), does not require bond hearings in which the government must prove dangerousness or flight risk by clear and convincing evidence. It left constitutional challenges to prolonged detention open for the lower courts.
One large question is still open. On October 1, 2026, the Supreme Court agreed to hear Rhoney v. Barbosa da Cunha (No. 26-104), which asks, in the Court's question presented, whether 8 U.S.C. 1225(b)(2)(A) mandates detention during removal proceedings of people who are in the United States without having been admitted. As of November 2026 the Court has not ruled. Its answer could decide whether many people who entered without inspection can ask an immigration judge for bond at all.
What this means for a reader: there is no simple national rule that six months of detention earns a bond hearing. Whether you can get one depends on which detention statute applies to you, what facts you can prove, and how the court in your area has ruled. If a criminal record is part of the picture, our guide to crimes that can get you deported explains how convictions feed into removal.
What happens after you file?
Federal law expects habeas to move quickly in theory. A judge "shall forthwith award the writ" or issue an order directing the respondent to show cause why it should not be granted, unless the application itself shows the person is not entitled to it. The writ or order goes to the person with custody, who must return it "within three days unless for good cause additional time, not exceeding twenty days, is allowed." Once it is returned, the court sets a hearing day not more than five days after the return, again unless there is good cause for more time (28 U.S.C. 2243). Real cases, especially state prisoner cases with long records, often move on court-set schedules instead of those short numbers.
If the district court denies a state prisoner's petition or a federal prisoner's 2255 motion, a further appeal needs permission first. Federal law says an appeal "may not be taken to the court of appeals" unless a circuit justice or judge issues a certificate of appealability, and that certificate may issue only if the applicant "has made a substantial showing of the denial of a constitutional right" (28 U.S.C. 2253(c)). Miss that step and the appeal is gone, no matter how good the claim is.
Filing does not by itself free anyone or stop a sentence. Release happens only if a court grants relief. Even a win often means a new trial or a new sentencing hearing, not an open door. If the claim is about a guilty plea, our guide to withdrawing a guilty plea explains the related ground rules.
What should you do if you think your detention is unlawful?
Write down which court convicted you or which agency holds you. That choice decides which federal statute is in play.
Get your court records: the judgment, the trial and plea transcripts, your appeal briefs and every order. Ask your former lawyers for their files.
Find the date your conviction became final and the dates of every state post-conviction filing. Mark each on a calendar and count days using the statute's rules for the one-year period.
List every claim you want to raise and check whether each one went through the state courts, all the way up. A claim missing from the state record may need a state proceeding first.
Look up your own state's post-conviction rules, because its filing windows and court names differ from other states and from the federal rules above.
Talk to a lawyer who handles post-conviction work. A public defender's post-conviction unit or a law school clinic may help, and so may a private attorney. Bring your calendar and records.
File in the right court, with every claim in the first petition, and ask for a certificate of appealability if you lose and want to appeal.
If you cannot afford a lawyer, federal law lets the court appoint one for a 2254 petition or a 2255 motion (28 U.S.C. 2254(h) and 2255(g)), but appointment is up to the court. For help in state post-conviction proceedings, check your state's public defender office, since eligibility varies by state and by type of case.
This is general legal information, not legal advice. Habeas rules are technical, they change, and state procedures differ, so check the official sources or speak with a licensed attorney in your state.
Frequently asked questions
What does habeas corpus mean?
Habeas corpus is a court proceeding that asks whether a person's detention is lawful. A judge can order the custodian to justify holding the person and can order release or a new proceeding if the detention violates the Constitution or federal law. It is used after convictions and in some immigration detention cases.
Is habeas corpus an appeal?
No. A direct appeal reviews errors in the trial record and comes first. Habeas is a separate proceeding that tests whether custody violates federal law. It usually follows the appeal and state post-conviction steps, and it has its own filing deadline and standards.
How long do I have to file a federal habeas petition?
Federal law sets a one-year limitation period for state prisoners under 28 U.S.C. 2244(d) and for federal prisoners under 2255(f). The start date depends on the case, usually when the judgment became final. State post-conviction deadlines vary by state, so check yours.
What is the difference between 2254 and 2255?
Section 2254 applies to people held under a state court judgment and is filed in federal court after state remedies are used. Section 2255 applies to federal prisoners attacking their sentence and is filed as a motion in the court that imposed it.
What does exhausting state remedies mean?
It means taking each claim through the state's available courts, including direct appeal and state post-conviction review, before going to federal court. Federal law generally bars relief for a state prisoner who has not exhausted, unless no state process exists or it cannot protect the applicant's rights.
Can I file a second habeas petition?
Only in narrow cases. A claim that was already raised is dismissed, and a new claim must meet statutory exceptions. You must first ask the court of appeals for permission, and a three-judge panel decides. The panel's decision cannot be appealed or taken to the Supreme Court on a petition for certiorari.
Can habeas corpus stop a deportation?
Habeas under 28 U.S.C. 2241 is mainly used to challenge detention, such as asking for release or a bond hearing, not to decide whether someone may stay in the country. What a court can order depends on the detention statute involved and current case law. As of November 2026, the Supreme Court is reviewing whether some people who entered without inspection must be held without bond.
Does a habeas petition get me released automatically?
No. Filing does not free anyone or pause a sentence by itself. Release happens only if a court grants relief, and relief often means a new trial or resentencing instead of immediate freedom.
28 U.S.C. 2253(c): Certificate of appealability needed to appeal
28 U.S.C. 2243: Writ procedure: return and hearing timing
This article is general legal information, not legal advice, and may not reflect the most current law or the law in your jurisdiction. Laws vary by state and change over time. For advice about your specific situation, consult a licensed attorney.
Knowing your rights is the first step
Join thousands committing to calmly and consistently exercise their constitutional rights.