If you move to Spain from another country to live, work or start a business, you will meet four procedures that sound alike and are not. Your permission to live here comes from immigration law (extranjería). Your identification number is the NIE. Your working life is tracked by Social Security (Seguridad Social) under its own number. And the tax you pay depends on something separate from all of these: your tax residence. Each one has its own law, its own office and its own deadlines.
This guide puts them in the order you will come across them. Each section sums up the rule, cites the article it comes from and links to the post that explains it in full. If you only need one part, jump to it from the contents list.
Four things not to mix up
Before each procedure, it helps to know what each word means. Many people assume that being registered at the town hall makes them resident for tax, or that the NIE lets them work. Neither is true.
| What it is | What it is for | Who gives it | Law |
|---|---|---|---|
| Legal residence | Lets you live in Spain (and, depending on the permit, work) | Immigration: the Oficina de Extranjería or the Police | Ley Orgánica 4/2000 and Real Decreto 240/2007 |
| NIE | Identifies you to every public body and is your tax number | Dirección General de la Policía (National Police) | Article 205 of Real Decreto 1155/2024 |
| Social Security number | Identifies you to Social Security to work, pay contributions and claim benefits | Tesorería General de la Seguridad Social (the Social Security treasury) | Article 21 of Real Decreto 84/1996 |
| Tax residence | Decides whether you pay IRPF on everything you earn worldwide or only non-resident tax on what you earn here | No one grants it: you either meet the test or you do not | Article 9 of Ley 35/2006 (the IRPF law) |
On top of these four sits the padrón, the register of residents kept by each town hall. We explain with examples how they fit together and when they do not match in tax residency versus legal residence.
Step 1: legal residence
The first step is being allowed to be in Spain. The rules depend on your nationality.
If you are a citizen of the European Union or the European Economic Area
For stays of under three months, a valid passport or national identity card is enough (article 6 of Real Decreto 240/2007). If you will stay longer, you have the right to reside if you work as an employee or are self-employed, if you have sufficient resources and health insurance or if you study with insurance and resources (article 7.1).
In that case you must apply in person to be entered in the Registro Central de Extranjeros (the central register of foreign nationals) within three months of arriving, at the Oficina de Extranjería in your province or, where there is none, at a police station. You are given a registration certificate on the spot showing your name, nationality, address, registration date and your foreigner identity number (article 7.5). This is the document many people call the "green certificate". If a family member of yours is not an EU citizen, they apply for a residence card for family members of an EU citizen within the same three months (article 8).
If you are from a country outside the European Union
Ley Orgánica 4/2000 separates two situations: a stay (estancia) and residence (residencia) (article 29). A stay lasts 90 days at most (article 30). To remain longer you need a residence authorisation, either temporary, for more than 90 days and less than five years (article 31), or long-term, which lets you live and work in Spain indefinitely (article 32).
To work, as an employee or self-employed, you also need a prior authorisation to reside and work, granted together with the residence one (article 36.1). It only takes effect once you are registered with Social Security (article 36.2).
If your visa or authorisation is for more than six months, you must apply in person for the foreigner identity card, the TIE (tarjeta de identidad de extranjero), within one month of arriving or of the authorisation being granted (article 4.2 of Ley Orgánica 4/2000 and article 209 of Real Decreto 1155/2024). The TIE is valid for as long as the authorisation it proves.
Step 2: the NIE, your number in Spain
The NIE (número de identidad de extranjero, foreigner identity number) is a personal, unique and exclusive number that identifies you on every document a Spanish public body issues to you (article 205 of Real Decreto 1155/2024). For the tax agency it is also your tax identification number: a foreign national's NIF is their NIE (article 20 of Real Decreto 1065/2007).
You need it for almost anything with an economic effect: signing a property purchase, registering as self-employed, being paid a salary, opening some accounts or filing taxes. It is granted by the Dirección General de la Policía.
- If you are going to live here: it is assigned automatically when your residence authorisation or registration certificate is processed.
- If your only link with Spain is economic, professional or social (for example, buying a home): you apply for it yourself, at an Oficina de Extranjería or police station or, if you are abroad, at a Spanish consulate. You have to give the reason and must not be in Spain irregularly. The application is decided within five days; if there is no answer in that time, it counts as refused (articles 205.3 and 205.4).
According to the National Police's online office, you apply with form EX-15 and proof of payment of the fee on form 790, code 012. Do not confuse the number with the document: the NIE is the number; the TIE and the registration certificate are documents that carry it. We explain this in what the NIE is and how to get it.
Each document also has its own support number (número de soporte), different from the NIE, which you are asked for when you register with Cl@ve (the government's online login system) or request your Renta reference number. We show where to find it in the support number on a DNI or NIE document.
Step 3: the padrón
Everyone who lives in Spain must register on the padrón of the municipality where they usually live (article 15 of Ley 7/1985, the local government law). The certificate of registration (certificado de empadronamiento) proves your address and is asked for in many procedures.
Two things are worth knowing. Being on the padrón does not prove that you live in Spain legally and gives you no rights that immigration law does not give you (article 18.2). And if you are not from the European Union and do not hold long-term residence, your entry lapses unless you renew it every two years (article 16.1).
Step 4: Social Security
Foreign nationals who live or are legally present in Spain and work here, as employees or self-employed, are covered by the Social Security system (article 7 of the Ley General de la Seguridad Social). Affiliation is compulsory, single for your whole life and for the whole system, even if you move between schemes (article 15).
To be affiliated you first need a Social Security number, which the Tesorería General assigns to each person to identify them as a member (article 21 of Real Decreto 84/1996). If a company hires you, the company applies for it (article 24). If you will work for yourself, you apply (article 25), online through Import@ss or at a Tesorería office. We go through it step by step in the Spanish Social Security number (NUSS).
If you come from another EU country, you may keep paying contributions at home during a temporary posting. That is decided by the EU coordination rules, starting with Regulation (EC) 883/2004, according to your own situation, so confirm it with Social Security before you start.
Step 5: your tax residence
This is the question that moves the most money: do you pay tax in Spain as a resident or as a non-resident? It does not depend on your permit, the padrón or the NIE. It depends on two tests in article 9 of Ley 35/2006 on IRPF (Impuesto sobre la Renta de las Personas Físicas, Spanish income tax). You are tax resident in Spain if either of these applies:
- you spend more than 183 days of the calendar year in Spain; sporadic absences count as days in Spain unless you prove you are tax resident in another country;
- or the main centre or base of your business activities or economic interests is in Spain.
You are also presumed resident if your spouse (not legally separated) and your dependent children under 18 usually live in Spain, unless you prove otherwise.
The tax works by calendar year (article 12): you are either resident for the whole year or not at all. Spain does not split the year you arrive into two parts. We go through it with examples in when you are tax resident in Spain.
If you are resident: IRPF on everything you earn
A resident pays IRPF on all their income, wherever it was earned (article 2 of Ley 35/2006). That includes rent from a flat back home, interest on a foreign account or a salary paid abroad. You declare it in the annual income tax return, the modelo 100 (modelo is what the tax agency calls each numbered form), using the progressive scale we explain in Spain's IRPF tax bands.
If you are not resident: non-resident income tax
A non-resident pays Impuesto sobre la Renta de no Residentes (non-resident income tax) only on what they earn in Spain (article 13 of the consolidated text approved by Real Decreto Legislativo 5/2004). The general rate is 24%, or 19% if you live in another EU or EEA country that exchanges tax information with Spain (article 25.1.a). If you own a home in Spain, you declare it on modelo 210: see our modelo 210 guide for non-residents.
Step 6: if another country also treats you as resident
Spain may treat you as resident while your home country does too. That is what double tax treaties are for. When both laws claim you, the treaty decides with a list of tests applied in order: where you have a permanent home, where the centre of your vital interests is, where you habitually live and, last, your nationality. Article 4.2 of the treaty between Spain and the United Kingdom, for example, says exactly this.
If you pay tax abroad on income that is also taxed in Spain, IRPF lets you deduct what you paid abroad, up to a limit: the lower of two amounts, the tax paid abroad or the Spanish tax due on that income (article 80 of Ley 35/2006). We explain it in what a double tax treaty does.
Step 7: the Beckham law, if you come to work
If you move to Spain for an employment contract, to become a company director or for certain entrepreneurial or highly qualified work, you can choose a special regime: you remain an IRPF taxpayer but pay under the non-resident rules, at 24% up to €600.000 and 47% above (article 93 of Ley 35/2006). It lasts for the year you become resident and the five years after.
The conditions are strict: you must not have been resident in Spain in the previous five years and must opt in with modelo 149 within six months of your Social Security registration. We explain every requirement in the Beckham law.
Step 8: if you will work for yourself
A foreign national can be self-employed (autónomo) in Spain and pays the same taxes as a Spaniard. If you are not from the European Union, you first need a residence and work authorisation that allows self-employment (article 36.1 of Ley Orgánica 4/2000). Once you have your NIE, the path is the same for everyone:
- Register with the tax agency (Hacienda) on modelo 036, where you choose your activity and your taxes.
- Register with the Social Security self-employed scheme on form TA.0521 and pay your monthly autónomo contribution.
- Get a digital certificate to file your taxes online.
- Issue invoices with IVA (Spanish VAT) and, when you work for companies or professionals, with IRPF withholding; every quarter, file modelos 303 and 130.
The full route is in how to become an autónomo in Spain. What changes for a foreign national is in foreign autónomos in Spain.
An example from start to finish
Lucía is Italian and moves to Valencia on 01/03/2026 to work as a freelance designer.
- Legal residence: as an EU citizen, she applies to the Registro Central de Extranjeros by 01/06/2026 at the latest, three months after arriving. She receives the registration certificate with her NIE.
- Padrón: she registers in Valencia at the flat she rents.
- Social Security: she requests her Social Security number and registers as self-employed.
- Tax agency: she registers on modelo 036 and starts invoicing.
- Tax residence: from 01/03/2026 to 31/12/2026 there are 306 days. She spends more than 183 in Spain, so she is tax resident for all of 2026. In her 2026 Renta, filed in 2027, she declares everything she earned that year, including January and February in Italy. If Italy also treats her as resident, the treaty between the two countries decides.
- Beckham law: it does not apply to her. Her freelance work is not one of the cases in article 93, which for the self-employed only covers entrepreneurial activities with a report from ENISA (the state innovation agency) and highly qualified professionals working for start-ups or in training, research, development and innovation.
Common mistakes
- Thinking the NIE lets you work. The NIE only identifies you. To work, if you are not from the European Union, you need a residence and work authorisation.
- Believing the padrón makes you tax resident. The padrón proves your address, not your tax residence or your legal residence.
- Declaring only what you earned after you arrived. If you are resident in a year, you are resident for the whole year and declare everything you earned in it, in Spain and abroad.
- Missing the six months of the Beckham law. If you do not file modelo 149 in time, you can no longer choose the regime.
- Forgetting income back home. Rent or interest outside Spain is declared here if you are resident; the treaty and the double tax deduction then stop you paying twice.
How Facturaz helps
If you will work as an autónomo, we can handle your autónomo registration for €49 + IVA and your digital certificate for €84 + IVA. After that, Facturaz prepares your modelos 303, 130, 111, 115, 349, 390 and 347 from your invoices and expenses: on Autónomo Go (€24 + IVA a month) you file them yourself with everything ready; on Autónomo Plus (€44 + IVA a month) our team files them and your Renta too. You can try it free for 14 days; prices are on the pricing page. We do not prepare Beckham regime returns (modelos 149 and 151).