Tax residence in Spain is regulated under article 9 of the Personal Income Tax Law. Individuals are resident in Spain for tax purposes if they meet at least one of the following criteria:

a) Spend more than 183 days in Spain during a calendar year.
b) Have Spain as their main base or centre of activities or economic interests.

183 day-rule:

Sporadic absences will count towards this time spent in Spain unless the taxpayer proves they are resident for tax purposes in another country, by providing a tax residence certificate issued by the tax authorities in that country. Although the tax residence certificate is the only means of proof of residence in another country allowed by the Spanish Tax Agency, in the past the Courts have allowed other types of proof such as rental agreements, utility bills, bank statements and others, taken together as a whole.
In the case of countries or regions considered tax havens, the Tax Agency may require proof that the individual spends 183 days in that country during a calendar year.
Temporary visits to Spain to comply with contractual obligations under cultural and humanitarian collaboration agreements with the Spanish authorities which are not remunerated are not included when calculating the 183-day residence period.

Main base or centre of activities or economic interests

This criterion is also important in determining tax residence. It is often overlooked on the basis of not having spent more than 183 days in Spain. The General Tax Department defines the taxpayer’s main base of economic interests as the place where the majority of their investments take place, where their business headquarters are located or where their assets are managed. It can also be the place where most of their revenues come from. The Supreme Court has specified that this criterion does not refer to personal, emotional or any non-economic ties, being limited to the taxpayer’s investments and sources of income.
To determine whether the main base of economic interests is in Spain and not another country, each specific case must be analysed. A series of circumstances need to be taken into account, such as no properties owned outside Spain, addresses registered with Social Security or banks, addresses specified on tax return forms, electricity consumption, professions, political and cultural activities, site of professional or commercial activities, or the place where their assets are managed (the “Saramago Case” in Spain). All of these taken together will determine the individual’s tax residence in Spain.
Unless proven otherwise, it will be assumed that the taxpayer is habitually resident in Spain when their spouse (not legally separated) and dependent children below legal age are habitually residents in Spain. However, if they actually reside in another country, the interested party must prove they are resident for tax purposes in the other country by providing a tax residence certificate issued by the tax authorities or other means of proof mentioned above.
Tax residence in Spain is for the whole tax year, from 1 January to 31 December, with no split-year treatment due to change of residence. For instance, if an individual becomes a resident in Spain in March, they will be considered a resident for tax purposes in Spain for the full year and will be taxed on their income from 1 January onwards.
Lastly, even if proof of residence in another country has been provided in the form of a tax residence certificate or any other means of proof, the Spanish Tax Agency can still consider them a resident in Spain if there is other evidence to indicate this. In this case, the dispute must be resolved by applying the tie-breaker rules included in the double tax treaty signed with the other country to determine in which country they are resident for tax purposes and consequently where they are subject to taxation on income earned anywhere in the world.