Spain's capital gains reinvestment relief
The rule everyone repeats is that you must reinvest everything you got. The regulation says otherwise.

TL;DR
If you sell your main home in Spain and buy another, the gain can be entirely exempt. What you must reinvest is not the sale price: article 41.1 of the regulation reduces it by the mortgage principal still outstanding on the day of the sale. The window is two years, and money paid for a home bought in the two years before also counts.
The short answer
Selling your main home in Spain produces a capital gain taxed in the savings base, at rates that today run from 19 to 30 per cent3. Article 38.1 of the income tax law allows it to be excluded from tax entirely if "the total amount obtained on the transfer is reinvested in the acquisition of a new main home"1.
The question that decides everything is what that total amount obtained is. Almost everything published answers that it is the sale price. The regulation answers something else.
What you must reinvest is not the sale price
The first paragraph of article 41.1 of the income tax regulation says it in as many words: where the taxpayer used borrowing to acquire the property being transferred, the total amount obtained is, for this purpose only, "the result of reducing the transfer value by the principal of the loan outstanding at the moment of the transfer"2.
Someone selling for 300,000 euros with 120,000 of mortgage still running does not have to reinvest 300,000. They have to reinvest 180,000. And that is not an arithmetic detail: it decides whether the relief is full or partial, and with it whether the return comes out at zero or several thousand euros of tax.
| A 300,000 € sale with a 120,000 € mortgage, costs ignored to isolate the effect | The usual reading | Article 41.1 |
|---|---|---|
| Amount you must reinvest | 300,000 € | 180,000 € |
| Reinvesting 180,000 € | partial relief | full relief |
| On a gain of 90,000 € | 36,000 € of the gain is taxed | nothing taxed |
The window is two years and it runs backwards as well
Article 41.3 gives two years from the transfer to reinvest, "in one go or successively"2. What is rarely added sits in the closing paragraph of the same section: amounts obtained on the sale and put towards a main home "acquired within the two years before" that sale also qualify for the relief.
The real window is therefore four years wide, and someone who bought the new home before selling the old one is still inside it. One formal duty is easy to lose sight of: if the reinvestment does not happen in the same year as the sale, the taxpayer must state the intention to reinvest in that year's return.
And if they then fail to, article 41.5 does not leave the matter open: the non-exempt part of the gain is attributed to the year it arose and a supplementary self-assessment with late-payment interest is due.
What counts as a "main home" here
Article 41 bis of the regulation defines the concept for articles 7.t), 33.4.b) and 38 of the law2: that is, for this relief and for the over-65 exemption at the same time. It asks two things:
- that the building has been your residence for a continuous period of at least three years;
- that you occupied it actually and permanently within twelve months of the acquisition or the completion of works.
The article itself opens the first condition: the home is treated as having been your main one even without the three years where the taxpayer dies or "other circumstances necessarily requiring a change of address" arise, and it lists marriage, marital separation, a job transfer, obtaining a first job and a change of job.
The two over-65 exemptions are not the same
They sit five articles apart and answer different questions. Confusing them makes someone pay who did not have to, or expect a relief that does not exist.
| Article 33.4.b) | Article 38.3 | |
|---|---|---|
| What is sold | The main home | Any asset |
| Must you reinvest | No | Yes, into an insured lifetime annuity |
| Deadline | None | Six months |
| Cap | No cap | 240,000 € |
| Covers severe dependency | Yes | Not mentioned |
Article 33.4.b) exempts the gain arising "on the transfer of their main home by people over 65 years of age or by people in a situation of severe or major dependency"1. No conditions. Article 38.3 exempts the transfer of any asset by someone over 65 "provided the total amount obtained on the transfer is used within six months to set up an insured lifetime annuity in their favour", and adds that "the maximum total amount that may be applied to setting up lifetime annuities shall be 240,000 euros"1.
A 66-year-old selling their house pays nothing and has to do nothing. The same person selling a second flat for 400,000 euros and putting all of it into a lifetime annuity is still taxed on 40 per cent of the gain, because the cap does not move.
Reinvest less and you do not lose it all
Article 41.4 and the second paragraph of article 38.1 say the same thing from both sides: where the amount reinvested is less than the total obtained, "only the proportional part of the capital gain corresponding to the amount reinvested shall be excluded from tax"12.
It is a proportion, not all or nothing. Against an amount to reinvest of 200,000 euros, reinvesting 50,000 exempts a quarter of the gain.
A worked example with real numbers
A main home bought in 2010 for 180,000 euros, with 15,000 euros of purchase costs and taxes, sold today for 300,000 euros with 12,000 euros of selling costs. 90,000 euros of mortgage was still outstanding.
| Item | Amount |
|---|---|
| Acquisition value (art. 35.1) | 195,000.00 € |
| Transfer value (art. 35.2) | 288,000.00 € |
| Capital gain | 93,000.00 € |
| Tax with no relief | 20,270.00 € |
| Amount to reinvest (art. 41.1) | 198,000.00 € |
Without the article 41.1 reduction, anyone reading that they must reinvest "everything obtained" will believe they need 288,000 euros. They need 198,000. And reinvesting that figure leaves the gain entirely exempt and the tax at zero rather than 20,270 euros.
The municipal plusvalía is separate: it is a town-hall tax on the increase in land value and is unaffected by this relief4.
Common mistakes
Believing you must reinvest the whole sale price
The first paragraph of article 41.1 of the regulation says that where borrowing was used to buy the property being sold, the total amount obtained is the transfer value reduced by the principal of the loan outstanding at the moment of the transfer. That is what turns many partial exemptions into full ones.
Thinking the window only runs forwards
The closing paragraph of article 41.3 says amounts put towards a main home acquired in the two years before the sale also qualify for the relief. Someone who bought first and sold afterwards is still inside it.
Not declaring the intention to reinvest
Where the reinvestment does not happen in the year of the sale, article 41.3 requires that intention to be stated in the return for the year the gain arose. It is a formal requirement that is easily forgotten and awkward to argue afterwards.
Mixing up the two over-65 exemptions
Article 33.4.b) exempts the sale of the main home with no condition and no cap. Article 38.3 exempts anything else only if the amount goes into an insured lifetime annuity within six months, and only up to 240,000 euros. Applying the second to a main home makes someone pay who did not have to.
Adding mortgage interest to the acquisition value
Article 35.1.b) includes the costs and taxes inherent to the purchase, EXPRESSLY EXCLUDING INTEREST. Twenty years of payments do not raise the acquisition value. And if you let the property, the depreciation you deducted LOWERS it.
Frequently asked questions
How much must I reinvest to pay nothing?
How long do I have to reinvest?
What counts as a main home?
What if I am over 65?
What if I reinvest only part of it?
What if I never reinvest?
Does renovating count instead of buying?
Does this relieve me of the municipal plusvalía too?
Related reading & calculators
Sources
- 1.Law 35/2006 on personal income tax, article 38: gains excluded from taxation on reinvestment · Boletín Oficial del Estado
- 2.Personal income tax regulation, article 41: the mortgage reduction, the two-year window and partial reinvestment · Boletín Oficial del Estado
- 3.Law 7/2024, seventh final provision: the 30 per cent savings-base band from 2025 · Boletín Oficial del Estado
- 4.Practical income tax manual, chapter 11: capital gains and losses · Agencia Tributaria
Author / Reviewed by
Author
Thorben Rasmus Idel
Co-founder & writer
Co-founder of Calculadora Capital and the writer behind the methodology on every calculator and article. An entrepreneur and active investor, Thorben founded Idel Versandhandel GmbH, an international trading company operating across 16 countries, and invests across stocks, ETFs and cryptocurrency. He writes the methodology and verifies the math behind each page, drawing on hands-on business and investing experience to keep the tools and explanations grounded in how money, markets and taxes actually work for everyday people in Spain.
Reviewed by
Nahar Geva
Co-founder & reviewer
Co-founder of Calculadora Capital and the independent reviewer behind every calculator and article. An entrepreneur and active investor, Nahar brings a data- and product-driven mindset together with hands-on experience in the markets, investing across stocks and ETFs as well as cryptocurrency and other digital assets, alongside broader personal finance and real estate. On each page Nahar reviews the methodology and double-checks the math and figures, pressure-testing how the tools and explanations hold up against the way money, markets and taxes actually work for everyday investors.
Published: Updated: Reviewed: