Custody Requirement. To apply for a writ of habeas corpus under § 2254, the petitioner must be in “custody,” a term that courts have liberally construed to include not only incarceration, but also other “significant restraints on petitioner's liberty.” Once a petitioner's sentence for a particular conviction has expired, the prisoner is no longer in custody under that conviction, and the sentence can no longer be challenged in an application for a writ of habeas corpus. However, so long as the petitioner was in custody when the writ was filed, the habeas corpus court has jurisdiction, which it retains pending a final disposition of the case.

In general, a petitioner may not challenge a current sentence that has been enhanced by a prior final conviction, unless the prior conviction was unconstitutionally obtained because of a failure to appoint counsel in violation of the Sixth Amendment. A conviction is final once the judgment is rendered, the defendant exhausts all direct appeals, and the time for filing a petition for certiorari on direct review lapses. A petitioner serving consecutive sentences is considered in custody under any one of them and may thus challenge any of the past or future consecutive sentences. A petitioner serving a federal sentence may even attack a consecutive state sentence that has not yet begun. However, petitioners serving concurrent sentences may not attack an expired concurrent sentence.