2026-06-14
Reinvestment in a Primary Residence: How It Works and What You Should Know Before Selling

Reinvestment in a Primary Residence: How It Works and When You May Benefit from the Tax Exemption
Selling a property may generate a capital gain and therefore have tax implications. However, when you sell your primary residence and reinvest the proceeds in the purchase of another primary residence, you may benefit from a capital gains tax exemption, provided that you meet the requirements established by the Spanish Tax Agency.
This exemption is particularly relevant for homeowners looking to move within Madrid, whether to gain more space, improve their location or purchase a property better suited to a new stage of life.
What qualifies as a primary residence?
To benefit from this exemption, the property sold must be your primary residence. As a general rule, you must have lived in the property continuously and effectively for at least three years.
Exceptions may apply in circumstances such as marriage, separation, job relocation, change of employment or any other situation that justifies a change of residence.
Second homes, rental properties and investment assets generally do not qualify for this exemption.
Time limit for reinvestment: two years before or after
The reinvestment must be completed within a maximum period of two years.
- You may purchase your new primary residence before selling the current one, provided the sale takes place within the following two years.
- You may also sell your primary residence first and purchase the new one within the following two years.
This flexibility is particularly useful in dynamic markets such as Madrid, where finding the right property can take time.
Moving into the new property
The newly acquired property must become your primary residence. Purchasing it is not enough; there must be a genuine intention to occupy it as your main home within the timeframes established by tax regulations.
Properties acquired for rental purposes, holiday use or investment purposes do not qualify for this exemption.
Full reinvestment: when the entire capital gain may be exempt
Full reinvestment occurs when the entire amount obtained from the sale is allocated to the purchase of the new primary residence.
In this case, the capital gain may be fully exempt from taxation, provided that all legal requirements are met.
Partial reinvestment: what happens if you do not reinvest the full amount?
If only part of the proceeds is reinvested, the exemption will apply proportionally.
The portion of the capital gain corresponding to the amount not reinvested may remain subject to income tax.
For this reason, before selling, it is advisable to calculate the sale price, estimated capital gain, outstanding mortgage balance and budget for the new purchase.
What happens if there is still an outstanding mortgage?
When the property being sold is subject to an existing mortgage, the reinvestment calculation must be carried out carefully.
The Spanish Tax Agency provides specific rules to determine the amount considered effectively reinvested when financing remains outstanding.
For this reason, it is advisable to consult a tax advisor before filing your income tax return.
Off-plan purchases and properties under construction
The reinvestment exemption may also apply to off-plan purchases or properties under construction, provided that all deadlines and tax requirements are respected.
People over 65 and common mistakes
Individuals over the age of 65 may benefit from a specific exemption on capital gains arising from the sale of their primary residence, even without reinvesting in another property.
Some of the most common mistakes include:
- Confusing a primary residence with a second home.
- Failing to comply with the two-year deadline.
- Incorrectly applying the exemption in cases of partial reinvestment.
- Failing to properly declare the transaction in the income tax return.
- Not keeping deeds, payment records and supporting documentation.
Poor planning may result in tax reassessments, interest charges or the loss of the tax benefit.
Advice before selling your primary residence
- Calculate the estimated capital gain.
- Confirm that the property qualifies as your primary residence.
- Determine whether the reinvestment will be full or partial.
- Coordinate the sale, purchase, financing and relocation process.
- Keep all documentation related to the transaction.
- Consult a tax advisor before filing your income tax return.
In prime real estate transactions, proper planning can have a significant impact on the final net result.
Achetez votre nouvelle résidence
How BARNES Madrid supports you
At BARNES Madrid, we assist you with the sale of your primary residence and the search for your new home in Madrid through a coordinated strategy that includes valuation, marketing, on- and off-market property selection and full support through to completion before a notary.
We work alongside your tax and legal advisors so that you can make informed decisions with confidence, particularly when your objective is to reinvest in a new primary residence.
If you are looking to sell and buy in Salamanca, Chamberí, Chamartín, Retiro, Justicia, La Moraleja, Aravaca or Pozuelo, we welcome you to our office at 15 Velázquez (Salamanca District). BARNES Madrid.

