A legal remedy against unlawful deprivation of personal liberty which is peculiarly applicable as to criminal prosecutions, although it is not expressly limited to such cases, is the writ of habeas corpus, which is granted by a court or judge on an application under oath alleging that some person named is illegally imprisoned or restrained of his liberty, and asking that the person exercising such imprisonment or restraint be required to come before the court or judge to show under what authority his power is being exercised. If the person against whom the proceeding is brought can show lawful authority, as where a parent is restraining his child, or a guardian his ward, or where an officer is imprisoning one accused or convicted of crime under legal process of arrest or by way of punishment lawfully imposed, then the proceeding will be dismissed; but if no lawful authority can be shown for the imprisonment or restraint, the court or judge hearing the case may order the person found to be illegally restrained set at liberty.

As applicable to criminal prosecutions, the proceeding by habeas corpus enables the court or judge before whom it is brought to inquire into the legality of the arrest of a person complaining of unlawful detention. If the accused has been refused bail, a proper method of securing the release on bail, if the offence is a bailable one, is by use of this writ. But the proceeding is not a method for revising or reviewing the action of the court which has jurisdiction to hold the accused for trial, or for freeing him from restraint under arrest or commitment for an offence charged so long as the court is proceeding lawfully and without violation of constitutional guaranties.

As a general rule one court will not by writ of habeas corpus interfere with restraint or imprisonment by virtue of the authority of another court; and the fact that the federal courts while acting within the scope of their authority are superior to the state courts, and are given ultimate power to determine the extent of their authority, renders it impossible for a state court to exercise jurisdiction by writ of habeas corpus to determine the legality of imprisonment or restraint under the authority of a federal court (Tarble's Case). One who is unlawfully imprisoned or restrained under the pretended authority of a federal court is not without redress, but he should seek it by application to a federal court or judge. On the other hand the federal judiciary in affording the protection guaranteed in the federal constitution as against state authority in particular classes of cases has the power to inquire into the legality of the proceedings of a state court if it is contended that under such authority a person is being deprived of some right guaranteed to him by the federal constitution. Therefore, a federal court or judge may in a habeas corpus proceeding determine the validity of proceedings under the authority of a state court (In re Neagle). But as the person who is unlawfully proceeded against in a state court has usually other remedies for the protection of his rights under the federal constitution, such as an appeal to the highest court of the state, and on denial there, an appeal to the Supreme Court of the United States, the federal courts will interfere by habeas corpus with proceedings under the authority of a state court only in a case of peculiar urgency, and will usually leave the complaining party to his remedy by appeal (Whitten v. Tomlinson).