Habeas corpus is the fastest legal mechanism to protect a person against illegal detention. If you or someone close to you has been detained and you believe their rights have been violated, this procedure allows you to demand that a judge review the situation within a maximum period of 24 hours.
Below we explain exactly what habeas corpus is, who can request it, in which cases it applies, and how the procedure works in Spain.
What is habeas corpus
Habeas corpus is a fundamental right recognized in Article 17.4 of the Spanish Constitution that guarantees personal liberty against arbitrary or illegal detentions.
Its specific regulation is found in Organic Law 6/1984, of May 24, which establishes a quick and simple judicial procedure so that any person deprived of liberty can be brought before a judge.
The objective is clear: to verify whether the detention complies with the law or whether, on the contrary, it must cease immediately.
What is habeas corpus for
Habeas corpus fulfills a function of judicial control over detentions. It serves to:
• Verify that the detention has a legal basis according to Article 492 of the Criminal Procedure Law.
• Guarantee that the rights of the detainee set out in Article 520 of the Criminal Procedure Law are respected.
• Control that the maximum detention periods are not exceeded.
• Order immediate release if the detention is illegal.
It is important to clarify that habeas corpus does not determine the innocence or guilt of the detainee. Its sole purpose is to review whether the deprivation of liberty complies with the law.
When does habeas corpus apply
According to Article 1 of Organic Law 6/1984, habeas corpus applies when a person is illegally detained. This includes the following situations:
Detention without legal basis. When the requirements of Article 492 of the Criminal Procedure Law are not met. That is, there is no evidence of a crime or there are no grounds to attribute participation to the detainee.
Violation of fundamental rights. When the rights of the detainee are not respected: legal assistance, right to remain silent, communication with family members, interpreter if necessary, or any other right under Article 520 of the Criminal Procedure Law.
Exceeding the detention period. The maximum period of preventive detention is 72 hours. If this is exceeded without the detainee being released or brought before a court, the detention becomes illegal.
Inhuman detention conditions. When the circumstances of detention violate the dignity of the person.
Who can request it
The standing to request habeas corpus is broad. The following may request it:
• The detainee themselves.
• The spouse, domestic partner, ascendants, descendants, or siblings of the detainee.
• The detainee's lawyer.
• The Public Prosecutor's Office.
• The Ombudsman.
The procedure does not require a lawyer or court representative on a mandatory basis, although having specialized legal assistance significantly increases the chances of success.
How to request it: step-by-step procedure
The habeas corpus procedure is designed to be quick and accessible:
1. Filing the application. It is submitted in writing to the Investigating Court on duty in the place where the detainee is located. A simple document identifying the detainee, the place of detention, and the reasons why it is considered illegal is sufficient. Only a signature is required.
2. Admission for processing. The judge examines the application immediately. If there are indications of illegality, they admit the procedure. If they consider that the application manifestly lacks grounds, they may deny it by reasoned order.
3. Judicial resolution. Once admitted, the judge must resolve within a maximum period of 24 hours. To do so, they may order the detainee to be brought before them, examine the circumstances of the detention, and hear both the detainee and the authority that ordered the deprivation of liberty.
4. Final decision. The judge may order immediate release, a change in the conditions of detention, or confirm that the detention is legal and dismiss the application.
How long does habeas corpus take
Habeas corpus is the fastest judicial procedure in the Spanish legal system. From filing the application to resolution, the maximum period is 24 hours.
This speed is essential because the right to personal liberty does not admit delays. Every hour of illegal detention constitutes a violation of fundamental rights.
What happens if it is denied
If the judge denies the habeas corpus application, the order can be appealed through an amparo appeal to the Constitutional Court for violation of the right to personal liberty (Article 17 of the Spanish Constitution).
However, the amparo appeal has specific deadlines and requirements that require specialized legal advice. It is essential to act quickly and have a lawyer with experience in criminal law and fundamental rights.
Difference between habeas corpus and amparo appeal
Although both protect fundamental rights, they are distinct mechanisms.
Habeas corpus is filed before the Investigating Court, while the amparo appeal is filed before the Constitutional Court.
Regarding deadlines, habeas corpus must be resolved within a maximum of 24 hours. The amparo appeal, on the other hand, can take months or even years to be resolved.
The subject matter of each procedure is also different. Habeas corpus is limited exclusively to illegal detentions. The amparo appeal can be filed for the violation of any fundamental right.
Regarding prior requirements, habeas corpus requires none: it can be filed directly. The amparo appeal, by contrast, requires first exhausting the ordinary judicial route.
Habeas corpus is the immediate route. Amparo is the subsidiary route when habeas corpus does not succeed.
Conclusion
Habeas corpus is a fundamental guarantee against illegal detention. It allows any person deprived of liberty to obtain a judicial review within a maximum period of 24 hours.
It applies when the detention lacks a legal basis, the rights of the detainee are violated, the legal deadlines are exceeded, or the detention conditions are inhuman.
If you believe that you or someone close to you is being illegally detained, act quickly. Contact a specialized criminal lawyer to file the habeas corpus application and protect your rights.

