The 183-day rule and centre of vital interests
Tax residency in Spain is determined by Article 9 of the Spanish Personal Income Tax Law (Ley 35/2006). Two tests operate independently: if either one triggers, you are Spanish tax resident for the whole calendar year.
The first test is 183 days of physical presence in Spain during a calendar year. Arrival and departure days both count. “Sporadic absences” abroad still count toward the Spanish total unless you can prove tax residency in another country during the absence. This catches Brits who think a long UK trip protects them — it does not, unless during that trip you were a UK tax resident.
The second test is centre of vital interests: where your spouse, dependent children, business activities, and most assets are located. This can override the day count. A British family who own a house in Madrid, send children to school in Madrid, and have most assets in Spain may be Spanish tax resident even if the working spouse is only physically in Spain 150 days a year.