How the Spanish Penal Code Treats Foreign Nationals
We explain when a criminal conviction can lead to deportation from Spain, the limits that apply and how it may affect immigration status.
5 min read

Foreign nationals are not subject to a separate Penal Code in Spain. When a foreign national commits an offence in Spain, Spanish criminal law applies in the same way as it does to any other person subject to the jurisdiction of the Spanish courts. However, being a foreign national can have specific consequences following a criminal conviction, particularly in relation to removal from Spanish territory and immigration status.
It is therefore important to distinguish between three concepts that are often confused: criminal liability, judicial deportation and administrative expulsion. They are not the same, they are not handled under the same procedure and their effects are different.
In this guide, we explain how the Spanish Penal Code treats foreign nationals, when a prison sentence may be replaced by deportation, what limits apply and how a criminal conviction can affect a person’s immigration status in Spain.
Does the same Spanish Penal Code apply to Spanish and foreign nationals?
Yes. Nationality does not exclude the application of Spanish criminal law when the Spanish courts have jurisdiction. A foreign national may be investigated, tried and convicted under the same criminal and procedural rules applicable in Spain.
The difference arises in certain consequences linked to the person’s status as a foreign national. The most relevant is the possibility, in specific cases, of replacing a prison sentence with deportation from Spanish territory under Article 89 of the Spanish Penal Code.
Judicial deportation of foreign nationals: what does Article 89 provide?
Article 89 regulates deportation as a possible substitute for certain prison sentences imposed on foreign nationals.
Prison sentences of more than one year
Where a prison sentence of more than one year is imposed, the Penal Code provides for its replacement by deportation from Spanish territory. However, the judge or court may exceptionally order that part of the sentence be served in Spain, up to a maximum of two thirds of its duration, where this is necessary to safeguard the legal order and the effectiveness of the rule that has been breached.
In these cases, the remaining part of the sentence may subsequently be replaced by deportation at the stage provided for by law, including when the person reaches third-degree prison classification or is granted conditional release.
Prison sentences exceeding five years
Where a prison sentence exceeds five years, or several sentences together exceed that period, the judge or court will order all or part of the sentence to be served in Spain to the extent considered necessary. The remaining part may subsequently be replaced by deportation.
Deportation is not automatic in every case
Article 89 also establishes an important limit: a prison sentence must not be replaced by deportation where removal would be disproportionate, taking into account the circumstances of the offence and the personal circumstances of the convicted person, particularly their ties to Spain.
This means that the length of the prison sentence is not the only factor. The court must assess the circumstances of the individual case before deciding whether deportation is appropriate.
What about EU citizens?
The Penal Code provides specific safeguards for citizens of European Union Member States. Their deportation may only be ordered where they represent a serious threat to public policy or public security, taking into account the nature and seriousness of the offence, the person’s criminal record and their personal circumstances.
Where the individual has resided in Spain for the previous ten years, Article 89 requires additional particularly serious circumstances before deportation may be ordered.
How long does judicial deportation prevent someone from returning to Spain?
Where deportation under Article 89 is enforced, the individual may not return to Spain for a period of five to ten years. The specific period depends on the sentence replaced and the person’s individual circumstances.
Deportation also leads to the closure of any administrative proceedings aimed at obtaining an authorisation to reside or work in Spain.
If the deported person returns to Spain before the court-imposed period expires, the sentences that were replaced may be reactivated under the conditions established in Article 89.
Offences for which the sentence cannot be replaced by deportation under Article 89
The Penal Code expressly excludes this mechanism for sentences imposed for certain offences. Article 89(9) refers to Articles 177 bis, 312, 313 and 318 bis, which concern, among other conduct, human trafficking, certain offences against workers’ rights and illegal immigration.
In these cases, the replacement of the prison sentence by deportation under Article 89 does not apply.
Judicial deportation and administrative expulsion are not the same
One of the most common sources of confusion is the difference between deportation ordered by a criminal court and expulsion under Spanish immigration legislation.
| Aspect | Judicial deportation | Administrative expulsion |
|---|---|---|
| Main legal basis | Article 89 of the Spanish Penal Code | Organic Law 4/2000 on foreign nationals |
| Origin | Criminal conviction | Administrative immigration procedure |
| Decision-maker | Judge or court | Competent administrative authority through a reasoned decision |
| Purpose in the context analysed | Replacement of certain prison sentences | Consequence established for certain immigration infringements or other situations provided for by law |
Article 57 of Organic Law 4/2000 regulates cases of administrative expulsion. Among other situations, certain serious or very serious infringements may result in expulsion instead of a fine, subject to the principle of proportionality and the corresponding administrative proceedings.
The same provision also addresses expulsion where a foreign national has been convicted, in Spain or abroad, of intentional conduct that would constitute an offence in Spain punishable by more than one year of imprisonment, unless the corresponding criminal record has been cancelled.
Can a criminal conviction affect a Spanish residence permit?
Yes, a conviction can have immigration consequences, but the effect depends on the person’s individual circumstances, type of residence authorisation and the procedure involved. A criminal record should therefore not automatically be equated with the loss of a residence permit.
When a renewal, modification or new immigration application is being considered, the person’s criminal and administrative situation should be reviewed together. In international mobility processes, this assessment is particularly important before an application is filed.
If you need to determine which authorisation allows a person to legally live and work in Spain, see our guide to the main types of work permits in Spain.
Rights of foreign nationals in legal proceedings
Being a foreign national does not remove the rights and legal safeguards recognised under Spanish law. Organic Law 4/2000 on the rights and freedoms of foreign nationals in Spain establishes the general framework governing the rights of foreign nationals and measures against discrimination.
Spanish immigration legislation also provides protections against discriminatory treatment and restrictions based solely on a person’s status as a foreign national or on other legally protected grounds.
Victims and situations with specific legal protection
Spanish legislation includes specific protection mechanisms for certain individuals. For example, Article 31 bis of Spain’s Immigration Law establishes safeguards for foreign women who are victims of gender-based violence or sexual violence, regardless of their administrative immigration status.
Where such circumstances reveal an irregular immigration status, the legislation provides specific measures regarding sanctioning proceedings and, in the cases established by law, the possibility of applying for residence and work authorisation on exceptional grounds.
These circumstances require an individual assessment and should not be confused with ordinary residence, employment or deportation procedures.
What should companies consider?
Criminal law can also intersect with the employment of foreign nationals. For businesses, prevention starts well before any potential sanction: each international employee’s authorisation should be checked to ensure that it is compatible with the position and the work they will actually perform.
Hiring a foreign national without the necessary work authorisation can expose the employer to administrative, financial and operational consequences. Our guide on what happens if you hire a foreign worker without authorisation explains the principal risks and the checks employers should perform before onboarding.
Companies that regularly recruit international talent should integrate immigration checks into their recruitment and mobility processes, rather than examining immigration, employment, Social Security and tax matters separately.
Immigration and international mobility advice in Spain
Where a criminal matter may affect a residence permit, work authorisation or international mobility process, the criminal and immigration implications should be reviewed together before decisions are made.
At Adlanter, our immigration team in Spain advises companies and individuals on visas, residence and work permits, permit modifications, renewals and other immigration procedures.
You can also learn more about our broader International Mobility services for companies managing expatriates and international employees.
Contact our team if you need to assess how an immigration situation may affect an international mobility or recruitment process.
This article is provided for general information only and does not replace legal advice on a specific case. Criminal and immigration consequences depend on the individual’s circumstances and the legislation applicable at the relevant time.

Do you have any questions?
If you have any questions after reading "How the Spanish Penal Code Treats Foreign Nationals", we are here to help you.
Let's talk. We guide you clearly and step by step.
