Foreign owners often end a period in Spain by selling the home and buying the next one elsewhere: back in their home country, closer to children, or in another place to retire. The Spanish gain can be large after years of ownership. Whether it can be exempt through reinvestment depends on two facts: your tax residence at the time of the sale and the country where the new home is.
The Spanish rule does not say "in Spain"
Article 38.1 of the Income Tax Act (Law 35/2006) exempts the gain on the sale of the main residence when the amount obtained is reinvested in "la adquisición de una nueva vivienda habitual". Neither that article nor article 41 bis of the Regulation, which defines the main residence, requires the new home to be in Spain. What they require is real residence: the new home must be occupied by you actually and permanently within twelve months of the purchase, and the reinvestment must take place within two years before or after the sale.
The DGT has said so expressly: anyone who is tax resident in Spain in the year of the sale can reinvest in a main residence in the country he or she moves to, even outside the EU (V1207-26, on Paraguay; also V2066-12).
Scenario 1: you are resident in Spain in the year of the sale
If you are tax resident in Spain that year, normally because you spend more than 183 days a year here or your main economic interests are here, the sale is declared in your Spanish income tax return. Buying a home abroad that you visit for holidays does not help: it is not your main residence. The exemption works if the foreign home becomes the place where you actually live, within twelve months. You do not have to remain resident in Spain after the sale (V1207-26).
Scenario 2: you move to another EU or EEA country
This is the most common case, and the law covers it expressly. The seventh additional provision of the Non-Residents' Income Tax Act (Royal Legislative Decree 5/2004) allows residents of another EU member state to exclude from tax the gain on the sale of what was their main residence in Spain if the total amount obtained is reinvested in a new main residence, applying article 38 of the Income Tax Act and its regulations. If only part is reinvested, the exemption is proportional. The same applies to residents of EEA states with effective exchange of tax information. Check with the Tax Agency which of them it treats as covered on the date of your sale.
In practice:
- the Spanish home must have been your main residence, normally for three years, and you must sell while it still counts as such: article 41 bis.3 accepts a sale within two years of the last day you lived there;
- the buyer still withholds 3 % of the price and pays it with Modelo 211, and you still file Modelo 210 for the gain within three months after the month in which the buyer had to pay that withholding;
- if you have already reinvested when the 210 is due, the exemption can be applied in it;
- if you reinvest later, you claim a refund with Modelo 228 within three months of acquiring the new main residence.
Scenario 3: you move outside the EU and the EEA
Residents of the United Kingdom, the United States, Switzerland and other third countries are not covered by the seventh additional provision. If you sell after becoming resident there, the gain is taxed in Spain as non-resident income at 19 %, with the 3 % withholding credited against the tax. The double tax treaty with your new country may give credit there for the Spanish tax, but it does not create a Spanish exemption.
The sequence therefore matters. A seller who completes the sale while still resident in Spain is taxed as a resident and can apply the reinvestment exemption under the general rules, subject to the new home becoming his or her main residence. The rules on when Spanish residence ends are strict, however, and are applied to the whole calendar year. Do not plan around them without advice.
Proving residence in the new home
Keep, translated where necessary:
- the title deed or purchase contract of the foreign property;
- registration with the local authority of the new place;
- utility bills, insurance and local bank records in your name at that address;
- a tax residence certificate from the new country if you claim to be non-resident in Spain;
- bank evidence of the payments made within the two-year period.
Worked example: moving to Portugal
Hans, a German national, lived in his house in Nerja from 2015. In March 2026 he moved to the Algarve, where he became resident. In November 2026 he sold the Nerja house for €420,000, with a gain of €160,000, and in June 2027 he bought his new home in Portugal for €450,000. The buyer withheld €12,600. Hans had not reinvested when his Modelo 210 was due, so he paid the tax on the gain, 19 %, crediting the withholding. Within three months of buying in Portugal he filed Modelo 228 to claim back the tax, since he reinvested more than the amount obtained.
Moves between countries raise residence, treaty and timing questions. Jacob Salama advises on the Spanish side in English and Spanish: contact us. The Spanish article is reinversión en vivienda en el extranjero.
Questions about reinvesting outside Spain
Does the new main residence have to be in Spain?
Article 38 of the Income Tax Act and article 41 bis of its Regulation speak of a new main residence without requiring it to be in Spain. What they require is that it becomes your actual, permanent home.
I am moving back to France and selling my Spanish home. Can I avoid Spanish tax on the gain?
If you are resident in another EU or EEA state when you sell, the seventh additional provision of the Non-Residents' Income Tax Act allows the gain on what was your main residence in Spain to be exempt if you reinvest the proceeds in a new main residence.
What is Modelo 228?
It is the Tax Agency's form for EU and EEA residents to claim a refund of non-residents' tax when they reinvest after filing Modelo 210. It must be filed within three months of acquiring the new main residence.
I am moving to the United Kingdom. Does the same rule apply?
The seventh additional provision covers only residents of EU and EEA states. A seller resident in the United Kingdom or another third country is not covered by it.
Last reviewed: 22 November 2026. General information on Spanish law in force; it does not replace advice on your specific case.
Further reading
