Selling your main home and buying another one is among the most common financial moves a family makes. It’s also one of the ones that raises the most tax questions. A sale often produces a capital gain for Spanish personal income tax (IRPF), sometimes a big one if you bought the property many years ago. The law lets you keep that gain tax-exempt if you reinvest the proceeds in a new main home.

So far, nothing new. The question that has fueled years of litigation is a different one: what counts as “reinvesting” when the new home is bought with a mortgage?

The starting point: what the law says

Article 38.1 of the IRPF Act allows the gain from selling your main home to be excluded from taxation. The condition is that you reinvest the full amount you received in buying a new main home. If you reinvest only part of it, the exemption is proportional.

Article 41 of the Regulation fills in the rules with these requirements:

  • Deadline: You must reinvest, in one go or in stages, within two years of the sale. A home bought two years before the sale also qualifies.
  • Amount to reinvest: This is the sale price minus selling costs. If the home you sold had an outstanding loan that gets paid off with the sale, that principal is deducted too. So, what you must reinvest is the “net” amount you end up with.
  • Main-residence status: The new home must become your main residence. As a rule, that means living there on a continuous basis for at least three years.
  • Election: You claim the exemption on the tax return for the year in which the sale took place.

None of these rules say how the new home must be paid for. That silence is where the dispute comes from.

The old approach: “physical” reinvestment

For years, the Tax Agency took a very restrictive view. It only counted money actually paid out within the two-year window. In practice, that meant counting the down payment on the purchase plus the loan installments paid off within those two years. The rest of the financing was left out.

The case the Supreme Court decided in 2022 shows what this meant in real life. A taxpayer sold his home in February 2010 and bought another in 2011 for €295,000. He paid €10,000 in cash, took over the seller’s mortgage of about €212,000, and deferred the rest. The Tax Agency counted only a little over €14,000 as reinvested: the down payment plus the installments for 2011 and 2012. As a result, it taxed almost the entire gain, even though he had bought a more expensive home than the one he sold.

The Administration’s argument was that if you finance a purchase, you’re not reinvesting, you’re just taking on debt. In its view, you only “reinvest” if you physically move the money from the sale into the purchase.

First step: the TEAC (2014)

The ruling of the Central Economic-Administrative Tribunal (TEAC) of September 11, 2014, issued to unify doctrine, already softened this view. The money used for the new home doesn’t have to be physically the same money you got from the sale. Investing an equivalent amount is enough. However, the question of third-party financing was still open.

The turning point: the Supreme Court (2020 and 2022)

STS 1239/2020, of October 1. The Supreme Court rejects the “physical” concept of reinvestment and adopts an economic one. There is reinvestment when the new asset, the new home, matches or exceeds the amount obtained for the old one. The Court stresses that neither the law nor the regulation requires a financial link between the money from the sale and the money used for the purchase. So, you don’t need to use the sale proceeds: it’s enough to put borrowed money from a third party toward the same purpose, whether directly or by taking over the seller’s mortgage.

STS 508/2022, of April 29. One last stronghold remained: the two-year deadline. Did the whole loan count, or only the part repaid within the deadline? The Supreme Court settles the question. The amount reinvested isn’t limited to what was actually paid out in those two years; it also includes the portions of the loan repaid afterward. The taxpayer in the case above won his appeal.

The finish line: the DGT adopts the criterion (V0266-23)

With binding ruling V0266-23, the General Directorate of Taxes (DGT) adopts the Supreme Court’s doctrine. The amount reinvested is the total purchase price of the new home paid within the deadline. It makes no difference whether it’s financed with a mortgage, a personal loan, or your own funds. The Tax Agency’s own Income Tax Manual now states this interpretation explicitly.

How the exemption works today, step by step

  1. Calculate the capital gain on the sale: sale value minus acquisition value.
  2. Calculate the amount to reinvest sale price minus costs and, where applicable, minus the outstanding loan principal that gets paid off.
  3. Compare it with the price of the new home bought within the deadline, regardless of how it’s financed.
  4. If the purchase price is equal or higher, the exemption is total. If it’s lower, the exemption is proportional: exempt gain = gain × (amount reinvested / amount to reinvest).

An example

Ana sells her home for €320,000, with €10,000 in costs. She bought it for €150,000, so her gain is €160,000. With the sale, she pays off €110,000 of mortgage, so the amount she must reinvest is €200,000.

Eight months later she buys a new home for €260,000. She puts in €40,000 of her savings and finances €220,000 with a new 25-year mortgage.

For anyone buying with a mortgage, the difference can run to tens of thousands of euros.

Practical tips

  • Plan your timing. The purchase must be completed within two years before or after the sale. If the reinvestment isn’t finished in the same tax year, you need to say so on your return.
  • Keep records of your financing. Hold on to the deeds, the binding mortgage offer, the amortization schedule, and proof of payments.
  • Mind the residency requirement. If you don’t live in the new home for three years, except for justified reasons, you could lose the exemption.
  • Review of past transactions. If the restrictive approach was applied on your own return, or in an audit of years that are still open, it may be worth looking into filing a correction or appealing the assessment.
  • Remember other exemptions. People over 65 who sell their main home get the gain exempted without having to reinvest.

Conclusion

The Supreme Court’s case law has given the exemption back its economic meaning. What matters isn’t where the money comes from, but that the taxpayer puts an amount equal to or greater than the sale proceeds into a new main home.

If you are thinking of selling your main home, or you have an open proceeding on this issue, feel free to get in touch.

Author:

Sergio Balagué

Partner, Tax Department, addwill