Habeas Corpus is a civil suit against the authorities including the warden of the prison challenging the constitutional validity of the sentence or the detention on the ground of deprivation of a constitutional right of the incarcerated person in course of the trial leading to the sentence. The writ of habeas corpus lies only when there has been denial of a constitutional right of the convicted defendant or violation of the due process norms.
A habeas corpus petition is not another appeal but a convicted defendant may file a writ of habeas corpus when he has exhausted recourse to all appeals without success. It is used to challenge convictions or sentences in breach of constitutional rights of the accused when no other remedies are available.
On the ground of violation of the rights enshrined in the US Constitution in course of trial, a detainee held by the federal authorities can file a petition of habeas corpus for reversal of his conviction or sentence.
Detainees under the state authorities can also file habeas corpus petitions against unlawful detention or confinement pursuant to the corresponding state constitutions.