Habeas corpus is the safeguard that allows anyone unlawfully detained in Spain to be brought immediately before a judge, who reviews whether the deprivation of liberty is lawful and, if it is not, orders their release. It is recognised in article 17.4 of the Spanish Constitution and regulated by Organic Law 6/1984 of 24 May (the Spanish habeas corpus statute). Its defining feature is speed: the judge must decide within a maximum of 24 hours of opening the procedure (art. 7). In a detention, those hours are everything.
What habeas corpus is
Habeas corpus is an urgent, priority procedure whose only purpose is to review the lawfulness of a detention. It does not try the offence or decide on guilt: it simply checks whether the person is deprived of liberty in accordance with the law and, if they are not, restores their liberty at once. That is why it is one of the most important safeguards against abuse in a detention.
This guide explains the Spanish habeas corpus, which is a specific procedure under Spanish law. It is not the same as the US habeas corpus of the suspension clause or the English writ of habeas corpus, even though all three share the same Latin name and the same underlying idea: no one should be held without a judge controlling that detention.
The two time limits you must not confuse: 72 hours and 24 hours
This is the most common confusion, and it is worth clearing up from the start, because they are two different things:
| Time limit | How long | Legal basis |
|---|---|---|
| Maximum length of the detention | The time strictly necessary and, as an absolute cap, 72 hours, after which the detainee must be released or brought before a judge | art. 17.2 of the Constitution |
| Ruling on the habeas corpus | 24 hours from the order opening the procedure (the auto de incoación) | art. 7 of Organic Law 6/1984 |
In other words: the police cannot hold a detention beyond 72 hours, and once a habeas corpus is sought the judge must rule on it within 24 hours. Habeas corpus exists precisely to react when those limits, or the safeguards attached to the detention, are not respected.
When it applies: the cases of unlawful detention
Article 1 of Organic Law 6/1984 treats as unlawfully detained, and therefore opens the door to habeas corpus, a person who falls into any of these cases:
Detained without the legal grounds or without observing the formalities
When someone is detained without the grounds the law allows, or without complying with the required formalities, such as informing the detainee of their rights or guaranteeing the assistance of a lawyer.
Held unlawfully in any establishment
Habeas corpus is not limited to police premises: it reaches any unlawful internment or deprivation of liberty in any establishment whatsoever.
Held in detention beyond the legal time limit
When the detention is prolonged beyond the legal limits without releasing the person or bringing them before the judicial authority.
Deprived of liberty in breach of their rights
When the deprivation of liberty disregards the rights that the Constitution and the procedural laws recognise to every detained person.
Who the competent judge is
As a general rule the competent judge is the Investigating Judge (Juez de Instrucción) of the place where the detained person is held; if that is not known, the judge of the place where the detention took place or of the last known whereabouts of the person (art. 2). In the detentions covered by article 55.2 of the Constitution the competent judge is the Central Investigating Judge (Juez Central de Instrucción), and in the military sphere, the Military Investigating Judge (Juez Togado Militar de Instrucción).
Who can request habeas corpus
Standing is deliberately broad, precisely so that the safeguard is effective. The procedure can be sought (art. 3) by:
- The person deprived of liberty themselves.
- Their spouse or the person linked to them by an analogous relationship of affection.
- Their descendants, ascendants and siblings.
- The legal representative of minors or of persons with a disability who need support.
- The Public Prosecutor (Ministerio Fiscal) and the Ombudsman (Defensor del Pueblo).
- The defence lawyer.
The judge may also start it of their own motion. You do not have to be Spanish or a resident: anyone detained in Spain can request it.
How to request it: the procedure step by step
The request is made to the competent Investigating Judge, in writing or by appearance in person, and from there the procedure moves very fast.
What the written request or appearance must contain
Article 4 requires three things:
- The name and circumstances of the person making the request and of the person deprived of liberty.
- The place where they are held and the authority or person in whose custody they are, if known.
- The specific reason why the detention is considered unlawful.
The law does not require a lawyer or court representative (procurador) to file it, but speed is everything: a criminal lawyer identifies the correct ground of unlawfulness and argues it in the first hours, and that is what decides the outcome.
From there: the authority holding the detainee must bring the matter to the judge’s attention immediately (art. 5); the judge examines the requirements, gives notice to the Public Prosecutor and, by order, either opens the procedure or rejects the request (art. 6, and that order cannot be appealed); once the procedure is opened, the judge orders the person to be produced, hears them together with the authority holding them, takes any relevant evidence and rules, all within 24 hours (art. 7).
What the judge decides: the effects of upholding it
The judge rules by reasoned order (art. 8). If the detention is lawful, the case is shelved. If the judge finds it unlawful, they may order:
- The release of the person.
- That the deprivation of liberty continues, but correcting the defects or under a different custody adjusted to the law.
- That the person is immediately brought before a judge, where the legal limit of the detention had already been exceeded.
Where the judge finds an unlawful detention, they additionally forward testimony (deduce testimonio) for the possible offences committed by whoever ordered or carried out the detention (art. 9).
If it is dismissed: the amparo appeal and other routes
The fact that the judge finds the detention lawful does not close off the defence. The right to liberty in article 17 of the Constitution is protected by the amparo appeal before the Constitutional Court (Tribunal Constitucional) under article 53.2 of the Constitution, and the strategy continues within the criminal proceedings themselves. This is why it is worth having a criminal lawyer assess the case from the very first moment: what is documented during the detention can be decisive later.
Habeas corpus and the amparo appeal are not the same. Habeas corpus is an urgent review of the detention before the Investigating Judge, who rules within 24 hours. The amparo appeal is brought before the Constitutional Court for the breach of the fundamental right, and it follows a separate and later route.
If you are a foreign national: interpreter and consular assistance
If you are detained in Spain as a foreign national, the same right to liberty protects you, and the law adds specific safeguards that are often where things go wrong, and therefore where a habeas corpus can be grounded.
Under article 520 of the Criminal Procedure Act (Ley de Enjuiciamiento Criminal, LECrim), every detained person must be informed in writing, in plain, accessible language and in a language they understand, of the facts attributed to them and the reasons for their deprivation of liberty (art. 520.2). The same article sets out the rights of the detainee, which include:
- The right to remain silent and not to answer any or some of the questions (art. 520.2.a).
- The right not to incriminate themselves and not to confess guilt (art. 520.2.b).
- The right to appoint a lawyer and to be assisted by them without undue delay (art. 520.2.c).
- The right to access the elements of the proceedings that are essential to challenge the lawfulness of the detention (art. 520.2.d): the very material that a habeas corpus turns on.
- The right to have a relative or chosen person informed of their detention and place of custody (art. 520.2.e).
- The right to be assisted free of charge by an interpreter, where the detainee is a foreign national who does not understand or speak Spanish (art. 520.2.h).
In addition, where the detainee is a foreign national, the consulate of their country is to be notified of the detention and the place of custody, and the detainee is allowed to communicate with the consular authorities (art. 520.3). If these rights are denied, for example a detainee who is not given an interpreter and is questioned without understanding what is happening, that is a breach of the safeguards of the detention and can be one of the grounds for a habeas corpus. If you have just been arrested, it is worth knowing what to do if you are arrested in Spain before anything else.
Habeas corpus and pre-trial detention: not the same thing
This is another common confusion. Habeas corpus reviews the lawfulness of a detention in its first hours; pre-trial detention (prisión provisional) is a precautionary measure ordered by a judge, within proceedings that are already open, to secure the presence of the person under investigation.
| Habeas corpus | Pre-trial detention | |
|---|---|---|
| What it is | Urgent review of a detention | Precautionary measure within the process |
| Who seeks it | The detainee, relatives, Prosecutor, Ombudsman, lawyer | The prosecution; ordered by the judge |
| Purpose | Check whether the detention is lawful | Secure the presence of the person investigated |
| Time | The judge rules within 24 hours | Reviewed according to the deadlines of the process |
The lawyer’s role in a habeas corpus
Although the detained person can request it themselves, in practice speed is everything. A criminal lawyer drafts and files a well-grounded request in the first hours, argues the specific ground of unlawfulness, and assists the person before the judge. Where the detainee is a foreign national, it also helps to have a lawyer who can act on the consular and interpreter rights from the outset, because the first decisions shape the entire defence. If you need a criminal defence lawyer in Spain, the first call should be made as early as possible.
A practical example
Imagine an illustrative case. A foreign national is stopped in the street and, because their identity document appears to be expired, is held at a police station. The hours pass without their being clearly informed of the reason, without an interpreter, and without being brought before a judge, and the detention drags on without justification. A relative contacts a criminal lawyer, who files a habeas corpus arguing that the detention is being held without respecting the safeguards. The Investigating Judge opens the procedure, orders the person to be produced and, having confirmed the irregularity, orders their release. This is a hypothetical example, but it reflects the typical situation: what habeas corpus protects is not the merits of the matter, but the lawfulness of the deprivation of liberty.
Frequently asked questions
How long does the judge have to decide a habeas corpus?
A maximum of 24 hours from the order opening the procedure (the auto de incoación). It is an urgent, priority procedure (art. 7 of Organic Law 6/1984).
How long can a police detention last before the person is brought before a judge?
The time strictly necessary and, at most, 72 hours; once that limit is passed, the person must be released or brought before a judge (art. 17.2 of the Constitution).
Who can request habeas corpus?
The detained person themselves, their spouse or partner, their ascendants, descendants and siblings, the legal representative where applicable, the Public Prosecutor, the Ombudsman and the defence lawyer. The judge may also start it of their own motion.
Do I need a lawyer to request a habeas corpus?
A lawyer or court representative is not required to file it, but having a criminal lawyer decisively improves both the request and the defence before the judge.
What is the difference between habeas corpus and the amparo appeal?
Habeas corpus is an urgent review of the detention before the Investigating Judge, who rules within 24 hours. The amparo appeal is brought before the Constitutional Court for the breach of the fundamental right and follows a separate and later route.
What happens if the habeas corpus is dismissed?
If the judge finds the detention lawful, it continues. That does not prevent a later amparo appeal before the Constitutional Court or other lines of defence within the criminal proceedings.
As a foreign national, am I entitled to an interpreter and to contact my consulate?
Yes. A detainee who is a foreign national and does not understand or speak Spanish is entitled to a free interpreter, and the consulate of their country is to be notified of the detention and place of custody (art. 520 of the Criminal Procedure Act). Denial of these safeguards can be a ground for a habeas corpus.
Does habeas corpus apply if the detention was without violence?
Yes. What matters is not whether force was used, but whether the deprivation of liberty is unlawful on any of the grounds in article 1 of Organic Law 6/1984.
If you or a relative have been detained in Spain and believe the detention is unlawful, contact a criminal defence lawyer in Spain immediately: in a habeas corpus, every hour counts.
Official source: Organic Law 6/1984 of 24 May, regulating the Habeas Corpus procedure (BOE).
