Habeas corpus in Spain: when to request it and how it works

If a detention is unlawful or goes on without reason, the law allows you to ask a judge to review it immediately. We explain when and how.
Celeste Pérez Bleda, criminal lawyer in Alicante
Celeste Pérez Bleda
Criminal lawyer · Bar No. 7301 ICALI

Updated: 9 October 2026

Puerta con barrotes de un calabozo, símbolo de la detención que se controla con el habeas corpus
Quick answer

Habeas corpus is the procedure that allows a judge to check immediately whether a detention is lawful. It is guaranteed by article 17.4 of the Spanish Constitution and regulated by Organic Act 6/1984 (Ley Orgánica reguladora del procedimiento de habeas corpus). You can request it if you are detained without legal grounds, if the time limit is exceeded, if you are unlawfully confined or if your rights as a detainee are not respected. A written application or an oral request to the officers is enough, without a lawyer or court representative, and the judge must decide within 24 hours of admitting it.

Habeas corpus is one of the oldest safeguards against arbitrary detention and one of the least known. We explain when to request it, who can do so, how it works and what happens if the judge rejects it without examining it.

What habeas corpus is

Article 17.4 of the Constitution requires the law to regulate a habeas corpus procedure “to secure that any person unlawfully detained is immediately brought before a judge”. That law is Organic Act 6/1984 of 24 May.

It does not decide whether you are guilty or innocent: its purpose is for a judge to see your situation in person and check whether the deprivation of liberty complies with the law. According to the Constitutional Court (Tribunal Constitucional, STC 21/2014 of 10 February), its essence is that the judge personally checks the situation of the person requesting the review and gives them the opportunity to be heard.

It applies to deprivations of liberty not ordered by a judge: police detentions, detention by private individuals or confinement anywhere. If there is already a court order (auto) imposing pre-trial detention (prisión provisional), the route is to appeal it, not habeas corpus.

When you can request it: the four situations

Article 1 of Organic Act 6/1984 treats the following people as unlawfully detained:

Situation (art. 1 LO 6/1984) Examples
a) Detained without the legal grounds being met or without the required formalities You are arrested without any evidence of an offence; a private individual holds you without legal grounds.
b) Unlawfully confined in any establishment or place You are kept locked up in a place without any legal basis.
c) Detained for longer than the period laid down by law The police procedures are over and you are neither released nor brought before a judge, or the 72 hours are exceeded.
d) Deprived of liberty without their rights as detainees being respected You are not informed of your rights, you are not allowed to appoint a lawyer or you are refused an interpreter or a doctor.

As for the time limit, remember that preventive detention may not last longer than the time strictly necessary for the inquiries and, in any event, 72 hours (article 17.2 of the Constitution and article 520.1 of the Criminal Procedure Act, Ley de Enjuiciamiento Criminal, LECrim). We explain this in how long detention can last. The rights you must be read are in article 520.2 LECrim, and we summarise them in what to do if you are arrested.

Who can request it

Under article 3 of Organic Act 6/1984, the following may apply for habeas corpus:

  • The person deprived of liberty.
  • Their spouse or unmarried partner, descendants, ascendants and siblings.
  • Their legal representatives, if the person is a minor, and anyone providing support with powers of representation for this purpose, if the person has a disability and is subject to court-ordered support measures.
  • The detainee’s defence lawyer, an option added by Organic Act 5/2024, in force since 4 December 2024.
  • The Public Prosecutor (Ministerio Fiscal) and the Ombudsman (Defensor del Pueblo).

In addition, the competent judge may open the procedure of their own motion.

How to request it and how it works

  1. Application. In writing or orally (by appearing in person), without the need for a lawyer or court representative (procurador). It must state who is making the request and for whom, where the detainee is and who is holding them if known, and the specific reason (article 4).
  2. Immediate notification to the judge. If you request it while detained, the officers are obliged to notify the judge immediately; if they fail to do so, the judge will issue them with a warning, without prejudice to their criminal and disciplinary liability (article 5).
  3. Admission. The judge forwards the application to the prosecutor and, by court order, either opens the procedure or rejects the application as inadmissible. That decision cannot be appealed (article 6).
  4. Hearing. The judge orders the detainee to be brought before them or goes to where the detainee is. The judge hears the detainee, their lawyer if they have one, the prosecutor and the officers who made the arrest, and admits any evidence that can be taken on the spot (article 7).
  5. Decision within 24 hours. Everything must be done and decided within 24 hours of the order opening the procedure (article 7).

What the judge can decide

Under article 8, if the detention is lawful, the judge closes the case. If it is not, the judge orders release, that the deprivation of liberty continue in another place or under other custody, or that the detainee be brought before a judge immediately if the time limit has already been exceeded.

The judge will refer the matter for prosecution of any offences committed by those who ordered or maintained the detention (article 9). The Criminal Code punishes any authority or public official who prolongs a deprivation of liberty in breach of the time limits or safeguards with special disqualification from office for four to eight years (article 530). If the judge finds recklessness or bad faith on the part of the applicant, the judge may order them to pay the costs.

Competent judge

Jurisdiction lies with the investigating judge of the place where the detainee is held; if that is not known, with the judge of the place of arrest, and failing that, with the judge of the place where the detainee was last known to be (article 2). Following Organic Act 1/2025, article 88 of the Organic Act on the Judiciary (Ley Orgánica del Poder Judicial) assigns habeas corpus proceedings to the Investigating Sections of the Courts of First Instance (Secciones de Instrucción de los Tribunales de Instancia).

If the judge refuses to admit it: Constitutional Court case law

Sometimes a habeas corpus application is rejected at the outset on the grounds that the detention is lawful. The Constitutional Court considers this unconstitutional. In STC 21/2014 of 10 February, citing “repeated and unequivocal” case law (including STC 35/2008 and STC 95/2012), it held that refusing to admit an application because the detainee is not unlawfully deprived of liberty infringes article 17.4, because that amounts to deciding on the merits, which can only be done after the procedure has been followed.

Under that case law, there are only two legitimate grounds for refusing to admit an application:

  • That there is no deprivation of liberty that has not been ordered by a judge.
  • That the formal requirements of article 4 are not met.

In that case, the detainee claimed that he had not committed any offence and the court refused to admit the application. The Constitutional Court granted constitutional protection (amparo): habeas corpus does not decide on guilt, but it does check whether there was evidence justifying the detention.

As the order refusing admission cannot be challenged by an ordinary appeal, the route for contesting it is an application for constitutional protection (recurso de amparo) to the Constitutional Court. If you are in that situation, we can advise you through our criminal appeals page.

Important: habeas corpus does not replace your defence in the criminal proceedings, nor can it be used to argue about whether you are guilty. It is an urgent review of the lawfulness of the detention. Requesting it recklessly or in bad faith can lead to an order to pay the costs (article 9).

Foreign nationals: immigration detention, borders and CIEs

The Immigration Act (Ley de Extranjería, Organic Act 4/2000) provides for deprivations of liberty that are not criminal:

  • In expulsion proceedings, precautionary detention by the government authority lasts a maximum of 72 hours before confinement must be requested (article 61.1.d).
  • If entry is refused at the border and return is delayed by more than 72 hours, the authority must apply to the investigating judge to decide on the place of confinement (article 60.1).
  • Admission to a detention centre for foreign nationals (centro de internamiento de extranjeros, CIE) is ordered by a judge and lasts a maximum of 60 days (article 62).

While the deprivation of liberty is in police hands, without judicial involvement, it can be reviewed through habeas corpus if any of the situations in article 1 applies. Once confinement has been authorised by a judge, oversight lies with the Investigating Sections, which under article 88.2 of the Organic Act on the Judiciary monitor stays in CIEs and in border refusal rooms and hear complaints from detainees about their fundamental rights. If you are a foreign national, see our page for a criminal lawyer for foreign nationals; if you were detained on arrival, see also what to do if you are arrested at Alicante-Elche airport.

Habeas corpus in Alicante

In the Alicante judicial district, the application is decided by the Investigating Section on duty. According to the official Generalitat Valenciana directory, the Alicante Duty Court is at Avenida de Aguilera, 53 (03007 Alicante). If the person is detained in another municipality in the province, the duty court of the place where they are held will have jurisdiction.

The most effective approach is to request it as soon as the irregularity is detected and to state the specific reason: the time of the arrest, the failure to inform the detainee of their rights or the refusal to call the lawyer of their choice. Celeste Pérez Bleda has assisted more than 800 detainees and knows how these applications are handled at the duty court.

Frequently asked questions

Do I need a lawyer to request habeas corpus?

No. Article 4 of Organic Act 6/1984 expressly states that a lawyer or court representative is not required. You can request it in writing or orally from the officers holding you, who must notify the judge immediately. Even so, a lawyer helps to set out the specific reason and, since December 2024, the defence lawyer can request it directly.

How long does it take to decide a habeas corpus application?

The judge must carry out all the steps and give a decision within 24 hours of issuing the order opening the procedure, under article 7 of Organic Act 6/1984. Before that, the judge must decide whether to admit it, after forwarding it to the prosecutor.

What happens if the judge rejects habeas corpus without hearing me?

No ordinary appeal can be brought against the order rejecting it (article 6). If the rejection was based on the detention being lawful, the Constitutional Court considers that article 17.4 of the Constitution is infringed, because that requires the procedure to be followed (STC 21/2014). The route is an application for constitutional protection (amparo) to the Constitutional Court.

Does habeas corpus help if I am already in pre-trial detention?

It is not the appropriate route. Habeas corpus reviews deprivations of liberty not ordered by a judge. If a judge has already issued a pre-trial detention order, the proper course is to appeal it, and the appeal must be decided within a maximum of 30 days (article 507 of the Criminal Procedure Act), or to request a review if circumstances change.

If you or someone close to you is detained in Alicante and you believe the detention is unlawful, message us on WhatsApp at 607 449 491 (24 hours). We assess whether habeas corpus is appropriate and are with you from the very first moment; our team will assist you in English. Here is how we work as an arrest lawyer available 24 hours in Alicante.

Contents

Are you involved in criminal proceedings?

We explain your options and the next steps. Urgent assistance 24 hours a day.

Do you need a criminal lawyer?

We are available 24 hours a day. Your first case assessment is confidential.
Can I help you?