WhatsApp and email answered by the lawyer himself.Book a call

Mortgage and reinvestment

Mortgage cancellation and main residence reinvestment: what is deducted

If you sell your main residence in Spain and use the price to repay the loan with which you bought it, the outstanding capital is deducted from the amount you must reinvest. Article 41.1 of the Income Tax Regulation says so. A loan taken out for another purpose, as in ruling V2151-24, is a different matter.

By Jacob Salama, Main Home Reinvestment Lawyer · Málaga Bar 11.294Updated 30 November 20264 min read
In short: amount to reinvest = transfer value (price less the selling costs you bear) − outstanding capital of the loan with which you bought the home you are selling. Repaying that loan is not reinvestment, but it lowers the amount to be reinvested.

1. What the Regulation says about the outstanding loan

Article 38.1 of the Income Tax Act requires reinvestment of the total amount obtained on the sale. Article 41.1 of the Regulation explains what that means where there was a loan: when external financing was used to acquire the home transferred, the total amount obtained is, for this purpose only, the transfer value reduced by the principal of the loan still outstanding at the time of the transfer.

  • What is deducted is the outstanding principal on the date of sale, not interest or fees.
  • The loan must have financed the purchase of the home you are selling. It need not be a mortgage loan.
  • The rule only affects how much must be reinvested. It does not reduce the capital gain.

2. How the Directorate General of Taxes applies it

Ruling V2245-25, of 25 November 2025, concerns an owner about to sell a mortgaged home and buy another. The amount to reinvest is the sale price less the costs inherent in the sale paid by the seller and, where the home was acquired with external financing, the difference between that amount and the loan principal outstanding at the time of the sale.

Ruling V2728-23, of 6 October 2023, separates the seller's debts: only the outstanding principal of the loan that financed the purchase is deducted. Personal loans repaid with the proceeds are not.

3. Ruling V2151-24: a mortgage taken out for something else

V2151-24, of 9 October 2024, is sometimes quoted as saying that cancelling a mortgage never reduces the amount to reinvest. It does not say that. The taxpayer had bought a plot in 2022 and mortgaged her previous home to pay for it. She then sold that home, repaid the mortgage and used the rest to build. The loan had not financed the purchase of the home she sold. In that case the DGT required the whole amount received to be reinvested in the construction within two years before or after the sale, counting what was paid for the new home with own or borrowed funds.

4. What the Supreme Court and the TEAC actually decided

  • Judgment 1239/2020, of 1 October (appeal 1056/2019, CENDOJ): the same money need not be used; borrowed money applied to the same purpose is enough.
  • Judgment 1098/2020, of 23 July (appeal 4417/2017, ROJ STS 2698/2020, CENDOJ): where the new home is under construction, the works must finish within four years of the start of the investment.
  • TEAC 00/02463/2013, of 11 September 2014 (as quoted in V2151-24): an amount equivalent to the total obtained must be invested in time, but not necessarily with the same funds.

None of them sets aside the rule in article 41.1 on the outstanding principal.

Jacob Salama, international tax lawyer, in his office

5. Examples in figures

Example 1: loan used to buy the home

Sale price €400,000, selling costs €12,000, outstanding purchase loan €150,000. The amount to reinvest for full exemption is 400,000 − 12,000 − 150,000 = €238,000.

Example 2: partial reinvestment

Sale price €300,000, selling costs €8,000, outstanding purchase loan €120,000: the amount obtained is €172,000. The gain is €80,000 and the new home costs €129,000 including purchase costs. That is 75 %: €60,000 is exempt and €20,000 is taxed, about €4,080 on the savings scale (1,140 + 2,940) if there is no other savings income.

Example 3: loan for another purpose

Sale price €350,000, selling costs €10,000, and €100,000 repaid on a loan used to buy a plot. Following the approach in V2151-24, the amount obtained is €340,000, with no deduction for that loan.

6. If you reinvest by building your new home

  • Payments: only those made within two years before or after the sale count.
  • Works: according to the Supreme Court and the DGT, they must finish within four years of the first payment treated as reinvested, with the extensions in paragraphs 3 and 4 of former article 55 of the Regulation.
  • A pending case: by order of 12 November 2025 (appeal 7688/2024, ROJ ATS 10370/2025) the Supreme Court admitted an appeal on whether that four-year limit still applies after article 55 was repealed. Until it is decided, the prudent course is to meet it.

See self-build and homes under construction.

7. Filing mistakes we see

  • Not deducting the outstanding purchase loan, which leads to a smaller exemption than is due. You may be able to amend the return.
  • Deducting debts that did not finance the purchase of the home sold.
  • Subtracting the loan capital from the gain. Only costs such as the registry cancellation of the mortgage are selling costs (DGT V1177-20).
  • Not stating the intention to reinvest when the reinvestment is not completed in the year of the sale (article 41.3).

More in reinvestment with a mortgage and partial reinvestment. Sources: article 38 of Law 35/2006 and article 41 of Royal Decree 439/2007 (BOE, in Spanish).

Questions about the loan on the home you sold

Does the loan on the home I sell reduce what I must reinvest?

Yes, if that loan financed the purchase of the home you are selling. Article 41.1 of the Regulation treats as the total amount obtained the transfer value less the principal outstanding at the time of the sale.

I mortgaged my home to buy a plot. Is that deducted too?

The rule refers to financing used to acquire the home transferred. In ruling V2151-24, where the mortgage was taken out to buy the plot, the DGT worked with the full amount received on the sale.

Which selling costs reduce the amount obtained?

Costs and taxes inherent in the sale that you pay as seller, such as the municipal plusvalía, the agent's fee or the registry costs of cancelling the mortgage, provided you can prove them.

I cannot reinvest everything. Do I lose the whole exemption?

No. It is proportional: the part of the gain that corresponds to the amount reinvested is exempt and the rest is taxed (article 41.4 of the Regulation).

Jacob Salama

Jacob Salama

Main Home Reinvestment Lawyer · Málaga Bar 11.294

Member of the Málaga Bar (no. 11.294) and managing partner of SALAMA LEGAL, S.L.P. He advises individuals on Spanish income tax and cross-border taxation and reviews the content of this website himself.

About the lawyer (ES) · Book a call

Last reviewed: 30 November 2026. General information on Spanish law in force; it does not replace advice on your specific case.

Further reading

Talk to the lawyer

Before you sign the sale, let a lawyer check your exemption

One wrong date or figure can cost you the whole exemption. We review your case and tell you how much you can save.

Book a callWhatsAppContact form
Book a callWhatsApp