The U.S. Constitution states that law enforcement officers can't put you in prison without following certain rules. If they make a legal mistake when arresting you, or if the court made a mistake when ordering you to prison, you can ask the court for a writ of habeas corpus. If you win, you must be released from prison.
The Process Begins With a Petition
You or your criminal defense lawyer must begin the habeas corpus process by letting the court know that you think your imprisonment is illegal. This involves filing a petition with the court that explains why you should not be in jail - such as the court set the wrong amount of bail or law enforcement violated your rights when they took you into custody. Your petition is a lawsuit. You're suing the person who is holding you in prison - which is technically the warden.
You Can Only Petition From Prison
Asking the court for a writ of habeas corpus is not the same as proving you're innocent of the charges against you. You generally cannot state in your petition that you didn't do what the state is accusing you of. That's a different matter and is decided at trial. You can't ask for a writ if you're already out on bail. You can only petition if you're in custody.
You May Be Given a Hearing
When the court receives your petition, a judge will decide if the state really did make a mistake, giving you the right to ask for your release. If so, the court will send a writ of habeas corpus to your warden, demanding that a prison official bring you to the courthouse on a certain date for a hearing.
The prosecutor will speak at the hearing and will try to convince the judge that the state did nothing wrong. You'll have a chance to argue your side of the story as well. The judge presiding over this hearing cannot be the same judge who ordered you to jail in the first place.
You Can Challenge the Court's Decision
If the judge denies your request for freedom, you have a short time to appeal the decision - usually about a month. If you're successful, the state will release you from jail. You'll still have to deal with the criminal charges that were the reason you were arrested in the first place, but the state usually can't put you back in jail until after your trial - and then only if you're found guilty.
A Criminal Lawyer Can Help
The law surrounding using habeas corpus to get out of prison is complicated. Plus, the facts of each case are unique. This article provides a brief, general introduction to the topic. For more detailed, specific information, please contact a criminal lawyer.