Tax residence
183 days is not the only rule
Being tax resident in Spain does not depend on having a NIE or being registered on the town hall register (padrón). Under the Spanish Personal Income Tax Act (Ley 35/2006, article 9), you are resident if you spend more than 183 days in Spain in the calendar year, and sporadic absences count towards those days unless you prove tax residence in another country (for countries treated as tax havens, the Tax Agency may require proof of 183 days spent there). You are also resident if Spain is the main centre or base of your business activities or economic interests. And you are presumed resident, unless you prove otherwise, if your spouse, not legally separated, and your dependent minor children live habitually in Spain. If your other country also treats you as resident and there is a double taxation treaty, the treaty rules decide. Counting days and ignoring the rest is a frequent mistake.
If you rent out a property in Spain and live abroad
As a general rule, a non-resident pays 24% on the gross rental income, with no expenses deducted. If you are tax resident in another European Union country, or in a European Economic Area country with an effective exchange of tax information, the rate is 19% and you may deduct expenses, provided you can prove they are directly related to the income earned in Spain (Non-Resident Income Tax Act, Real Decreto Legislativo 5/2004, articles 24.6 and 25.1.a). Without supporting documents, the deduction cannot be applied. The United Kingdom, the United States and Switzerland are not in the European Union or the European Economic Area. And leaving the property empty or keeping it for your own use does not exempt you from filing: the law treats an imputed income from urban property not used for a business as income obtained in Spain (article 13.1.h).