Taxation in Madrid

2026-10-02

How Does Reinvestment in a Main Residence Work After Selling a Home in Madrid?

Reinvestment in a Main Residence: Complete Guide | BARNES Madrid News


Reinvestment in a main residence: how the personal income tax exemption works












Selling a property in Madrid may generate a capital gain that must be declared for Spanish personal income tax purposes. However, when the property sold is the taxpayer’s main residence and the proceeds are used to purchase or renovate a new main residence, the main residence reinvestment exemption may apply.

This tax relief is particularly relevant for owners who sell one home in order to buy another: families needing more space, couples moving to a different area, owners looking for a more comfortable property, buyers moving from an apartment to a house, or people selling a prime property in order to acquire another home in Madrid or another city.

Reinvestment in a main residence can result in significant tax savings, but specific requirements must be met. It is not enough simply to sell one home and buy another. The applicable deadlines must be respected, the transaction must be declared correctly and both the property sold and the new property must qualify as the taxpayer’s main residence.






What is reinvestment in a main residence?

Reinvestment in a main residence occurs when you sell your main residence and use the amount obtained to acquire another property that will also become your main residence.

The exemption does not apply automatically. The taxpayer must indicate their intention to benefit from it, and the tax relief is conditional on both the property sold and the new property acquired, or renovated, qualifying as a main residence.

The reinvestment must also be completed within the periods and under the conditions established by law.

In other words, if you sell your main home in Madrid and purchase another main residence within the legal timeframe, the capital gain generated by the sale may be fully or partially exempt.






Why does this exemption exist?

The reinvestment exemption is intended to avoid an excessive tax burden when a taxpayer changes their main residence without retaining the sale proceeds as permanent liquidity, but instead uses the money to finance another primary home.

In real life, housing needs change. A couple may need additional bedrooms after starting a family. Someone may sell a large apartment in order to move to a more practical home. A family may relocate because of schools, work, accessibility or a move to another city.

An owner may also decide to move from a city-centre apartment to a house in a residential development, or from a large family home to a more manageable apartment.

The rules protect this type of transaction provided that the relevant requirements are met.






What is considered a main residence?

This is one of the most important points. Not every property qualifies for the exemption. It must be the taxpayer’s main residence.

As a general rule, a main residence is a property in which the taxpayer has lived continuously for at least three years.

For the reinvestment exemption to apply, the property sold must have been the taxpayer’s main residence for a continuous period of at least three years and the taxpayer must have held full ownership during that period.

Exceptions may apply where circumstances require a change of residence before the three-year period has elapsed, such as marriage, separation, relocation for work, obtaining a first job, changing employment or other justified circumstances that make the move necessary.






How long do you have to reinvest?

The general period is two years. The reinvestment may take place after the sale of the main residence or before it.

The amount obtained must be reinvested, either in a single payment or in successive payments, within a period of no more than two years, calculated from date to date.

This allows for two common situations:

  • You sell your main residence and buy a new one within the following two years.
  • You first purchase a new main residence and sell the previous one within two years of that purchase.

In both cases, the exemption may apply if all other requirements are met.






When must you start living in the new property?

The new property must also become your main residence. Simply purchasing it is not enough. It must genuinely be used as your usual home.

As a general rule, the taxpayer must occupy the new property within the applicable period following acquisition, or following completion of the works if the property is being renovated or constructed.

This is particularly relevant for new-build properties, major renovations and off-plan purchases.

If you buy a property that cannot yet be occupied because it is under construction or requires renovation, the process should be properly documented and the applicable deadlines must be respected.






How much must be reinvested?

To qualify for the full exemption, the full amount obtained from the sale of the main residence must be reinvested, taking into account the applicable rules where outstanding financing exists.

The sale price should not be confused with the capital gain. The exemption applies to the gain, but the reinvestment requirement refers to the amount obtained from the sale.

For example, if you sell your main residence for €900,000 and reinvest the full amount that must be taken into account for tax purposes in a new main residence, the capital gain may be fully exempt.

If you reinvest only part of the amount, the exemption will be partial.






Full reinvestment

Full reinvestment occurs when the entire amount obtained from the sale is used to purchase or renovate the new main residence.

In this case, the capital gain generated by the sale may be fully exempt from Spanish personal income tax, provided that the requirements concerning the main residence, timing, declaration and use of the funds are met.

This is common when an owner sells one property and buys another of equal or greater value, or when all the funds received are allocated to the new purchase.






Partial reinvestment

Partial reinvestment occurs when only part of the amount obtained from the sale is used to acquire the new main residence.

In that case, the exemption applies proportionally.

If you sell your main residence and reinvest only part of the proceeds, you will have to pay tax on the portion of the capital gain corresponding to the amount not reinvested.






Practical example of full reinvestment

Imagine that you sell your main residence in Madrid for €700,000. You originally purchased the property several years ago for €450,000 and, after taking costs and taxes into account, a capital gain arises.

If you use the relevant amount to purchase a new main residence for €700,000 or more and comply with the legal deadlines, you may qualify for a full exemption on the capital gain.

This does not mean that the sale does not have to be declared. The transaction must still be included in your income tax return and the reinvestment must be reported correctly.






Practical example of partial reinvestment

Now imagine that you sell your main residence for €700,000 but reinvest only €500,000 in the new main residence.

In this case, the reinvestment is not complete. The capital gain will only be exempt in proportion to the amount actually reinvested.

The remaining portion will be subject to Spanish personal income tax.

This is particularly relevant where an owner sells a larger property and buys a smaller one while retaining part of the proceeds as liquidity.






Buying before selling: a very common situation

In Madrid, it is common for an owner to purchase a new home before selling the previous one.

This may happen because suitable properties are scarce, because the buyer wants to secure a particular opportunity or because the new property requires renovation.

This sequence may still qualify for the exemption, provided that the previous main residence is sold within the two-year period and the remaining requirements are met.

Buying before selling therefore does not necessarily prevent the exemption from applying. The key is to structure the transaction correctly and retain clear evidence of the payments.






What happens if you buy with a mortgage?

Mortgage financing is one of the areas that generates the most questions.

You may purchase the new main residence using a mortgage and sell the previous property afterwards.

Using financing does not, by itself, prevent the exemption from applying, although it can make the calculation more complex.

It is important to determine how the proceeds from the sale are used and what portion can genuinely be treated as reinvested.

For high-value transactions, financing should ideally be planned before signing a deposit agreement.






Selling with an outstanding mortgage

If the property you are selling still has an outstanding mortgage, this must also be taken into account.

The amount obtained for reinvestment purposes may be affected by repayment of the outstanding loan.

In practice, if part of the sale price is used to repay the mortgage on the property sold, the amount regarded as obtained and the way in which it is reinvested must be calculated correctly.

This point should be reviewed with a tax adviser, particularly where mortgages, early repayments, previous purchases or several payment accounts are involved.






Renovation as reinvestment

Reinvestment does not have to be used exclusively to purchase another main residence.

It may also be used to renovate a property that will become the taxpayer’s main residence, provided that the relevant requirements are met.

This can be particularly useful if you sell one property and buy another that requires structural works or substantial renovation.

Not all works are treated in the same way for tax purposes. Cosmetic improvements, decoration or ordinary interior design works may not qualify as renovation for the purposes of the exemption.






New-build property and off-plan purchases

Purchasing a new-build or off-plan property may create uncertainty because the taxpayer cannot always occupy the property immediately.

In certain cases involving the construction of a main residence, the reinvestment deadline must be met together with the regulatory deadlines applicable to completion of the property.

If you buy off-plan in Madrid, it is advisable to keep all the relevant documentation: purchase contract, payment records, bank receipts, handover certificate, first occupancy licence, public deed and the effective date of occupation.






How reinvestment is declared for personal income tax

The sale of a main residence must be declared for Spanish personal income tax purposes even if the capital gain is exempt because of reinvestment.

Where the capital gain arises from the transfer of a main residence and the reinvestment exemption is applied, whether fully or partially, the corresponding information must be completed in the tax return.

In addition, if the reinvestment does not take place in the same year as the sale, the taxpayer must state their intention to reinvest within the legal period.






Common mistakes when applying the exemption

One of the most common mistakes is assuming that the exemption applies automatically. It does not. The transaction must be declared and the intention to benefit from the exemption must be stated.

Another frequent mistake is confusing a main residence with a second home. If the property sold was not your main residence, the reinvestment exemption will not apply even if you subsequently buy another property.

Other common mistakes include miscalculating the two-year period, failing to retain payment records, reinvesting only part of the proceeds while declaring full reinvestment, or using the funds for works that do not meet the tax definition of renovation.






Exemption for people over 65

Reinvestment is not the only possible exemption.

Taxpayers over the age of 65 may benefit from specific tax treatment when selling their main residence.

In certain cases, an owner over 65 may not need to reinvest the proceeds for the capital gain generated by the sale of their main residence to be exempt.

Nevertheless, each case should be assessed individually.






Separation, divorce and the main residence

Determining whether a property qualifies as a main residence can be more complex where there has been a separation, divorce or an award of the right to use the family home.

Specific criteria apply in cases where the taxpayer had to leave the family home because the right to use the property was granted to the other spouse.

In these situations, it is advisable to review the court judgment or settlement agreement and prepare the relevant documentation before declaring the transaction.






Bare ownership, usufruct and full ownership

Reinvestment requires particular attention where ownership rights are split, for example between bare ownership and usufruct.

To apply the reinvestment exemption, it is necessary to assess whether the taxpayer held full ownership for the required period.

This is particularly relevant in inheritances, gifts with retained usufruct and transactions where not all owners hold full ownership.

Before selling, the exact ownership structure and legal history of the property should be reviewed.






Which costs affect the capital gain?

The capital gain is not calculated simply by subtracting the original purchase price from the sale price.

In general terms, the calculation is based on the transfer value and acquisition value, adjusted by the expenses and taxes permitted under the applicable regulations.

Relevant costs may include notary fees, Land Registry fees, taxes paid on acquisition, professional fees connected with the purchase or sale and certain documented investments or improvements.

It is essential to retain invoices and supporting documents. For a high-value property, accurate documentation can have a significant impact on the tax calculation.






Reinvestment and buying a home in Madrid

Madrid presents particular circumstances due to its property prices, the diversity of its neighborhoods and the speed of the prime residential market.

Owners selling in established areas often need to buy before selling in order to secure the right opportunity.

This is common in areas such as Salamanca, Chamberí, Chamartín, Retiro, Justicia, Jerónimos, El Viso, Almagro, Recoletos, La Moraleja, Aravaca and Pozuelo.

In these markets, tax planning should go hand in hand with the real estate strategy.

Before selling, it is advisable to define your net budget, target purchase price, financing requirements, sale timetable and tax reinvestment deadline.






Full reinvestment or preserving liquidity: a wealth-planning decision

Fully reinvesting the proceeds is not always the best option. Some owners prefer to buy a less expensive property and retain part of the proceeds as liquidity.

In that case, the exemption will be partial, but the decision may still make sense from a wealth-planning perspective.

The question should not simply be “how much tax can I save?” but also “what wealth structure is most appropriate for me?”.

It may be preferable to pay tax on part of the gain and retain capital for investment, renovation, children, estate planning or personal liquidity.

The decision should be based on clear figures: estimated tax, purchase value, family needs and medium-term strategy.






Documents you should keep

To support the exemption properly, you should retain:

  • The purchase deed for the property sold.
  • The sale deed.
  • Evidence of expenses and taxes.
  • Municipal registration certificate where useful.
  • Utility bills.
  • Documents proving that the property was your main residence.
  • The purchase deed for the new property.
  • Payment receipts.
  • Construction contracts where renovation is involved.
  • Renovation invoices.
  • Mortgage documents, cancellations or repayments.
  • The personal income tax return in which the reinvestment is reported.
  • Any document supporting special circumstances.

A well-documented transaction reduces risk in the event of a tax review.






Checklist before selling your main residence

Before selling, review:

  • Whether the property qualifies as your main residence.
  • Whether you have lived there for at least three years.
  • Whether an exception justifies a shorter period.
  • The estimated capital gain.
  • How much must be reinvested to obtain the full exemption.
  • Whether you will buy before or after selling.
  • Whether you will require a mortgage.
  • Whether the new property will be your main residence.
  • Whether renovation or rehabilitation will be required.
  • How the transaction will be reported for personal income tax purposes.

This analysis should be carried out before the sale is signed, not afterwards.






Checklist before buying your new home

Before purchasing your new main residence, consider:

  • Whether the transaction falls within the two-year period.
  • Whether you will be able to occupy it as your main residence.
  • Whether works are required and what type of works they are.
  • Whether the price allows for full or partial reinvestment.
  • Whether you will use your own funds or financing.
  • Whether the property is correctly documented.
  • Whether the delivery schedule complies with the applicable requirements.
  • Whether you will retain evidence of all payments.

A rushed purchase can put the exemption at risk.






Frequently asked questions about reinvestment in a main residence

Do I have to reinvest specifically in Madrid?

No. The new main residence may be located in Madrid or another city, provided that it meets the legal requirements for a main residence.

Can I reinvest before selling?

Yes. Reinvestment may take place within the two years before or after the sale of the main residence.

Does the exemption apply automatically?

No. You must state your intention to apply the exemption and declare the transaction correctly.

What happens if I reinvest only part of the proceeds?

The exemption will be partial. You will pay tax on the proportional part of the capital gain corresponding to the amount not reinvested.

Can I apply the exemption if I buy a property to rent out?

No. The new property must be your main residence. A property purchased for rental purposes does not meet the requirements of the main residence reinvestment exemption.

Can I apply the exemption if I sell a second home?

No. The property sold must qualify as your main residence.

What happens if I do not reinvest within the deadline?

If you fail to meet the deadline or other applicable conditions, you will lose the exemption and will need to regularize the corresponding tax position.

Can renovation works be included?

It depends. The rules allow reinvestment in qualifying rehabilitation works, but not every cosmetic renovation or interior improvement necessarily meets that definition.

It is advisable to check this before including those amounts in the calculation.






Conclusion

Reinvestment in a main residence is an important tax mechanism for owners who sell one home and purchase another.

It may allow the capital gain generated by the sale to be fully or partially exempt from Spanish personal income tax, provided that the requirements relating to the main residence, timing, reinvestment and tax declaration are met.

In Madrid, where many transactions involve substantial amounts, careful reinvestment planning can make a significant financial difference.

Before selling or buying, it is advisable to calculate the capital gain, review the documentation, define the timetable and coordinate the transaction with appropriate tax and real estate advice.




Discover exclusive properties in Madrid




How BARNES Madrid can assist you

At BARNES Madrid, we assist you with the sale of your main residence and the search for a new property with a wealth, tax and real estate perspective.

We assess the sale timetable, purchase strategy, documentation, market value, financing and opportunities available in prime areas.

If you are looking to sell a property in Madrid, buy an apartment in Madrid or reinvest in a new main residence in Salamanca, Chamberí, Chamartín, Retiro, Justicia, Jerónimos, El Viso, Almagro, Aravaca, Pozuelo or La Moraleja, we provide access to selected on & off-market properties together with discreet and comprehensive advice.

Visit us at 15 Velázquez Street, in the heart of the Salamanca district. BARNES Madrid.