There are two main types of individual taxpayers in Spain: residents, who pay taxes based on world-wide income and world-wide assets, and non-residents, who only pay taxes on Spanish income and Spanish assets. This is completely separate from your residency permit or visa. You can be a legal resident but not a tax resident or vice versa.
If you live in Spain for more than 183 days a year, you are normally considered tax resident and pay income tax (IRPF) world-wide income, and wealth tax (Impuesto sobre el patrimonio) on your world-wide assets. Spain will give you a tax credit for income taxes you are required to abroad in most circumstances (except for US income taxes you pay as a consequence of being a US citizen), so you avoid double taxation in most cases.
If you want to avoid being taxed as a resident if you exceed 183 days, there are two legal ways to do it (that I know of):
- Apply for the Royal Decree 687/2005 (otherwise known as the Beckham law). This applies to foreigners who haven't lived in Spain for at least 10 years, who move to Spain in order to become an employee for a Spanish company.
- If you are a foreign national and have a home available to you in your country of origin, you may be able to have yourself certified as a tax resident of your country of origin. For example, in the US, this would done via a form 6166. If your country has a tax treaty with a "tie-breaker" clause, this can allow you to be a considered non-resident in Spain. Spain generally requires you to have a certificate of tax residency from your country of origin for this to work.
Beyond determining how you file for taxes, there are other implications:
- Bank accounts in Spain are either resident or non-resident. Resident accounts require documentation when making large transfers out of Spain, whereas non-resident accounts do not.
- Spanish tax residents pay wealth tax on world-wide assets, whereas non-residents only pay on Spanish assets. If you are a non-resident, keeping your investments outside Spain is a really good idea.
- Spanish tax residents are required to declare world-wide assets on the Modulo 720 form if assets outside Spain exceed €50,000..