Capital Gains Tax Exemption When Buying Your Main Home on the Costa del Sol in 2026: Habitual Residence Rules for Expats

Capital Gains Tax Exemption When Buying Your Main Home on the Costa del Sol in 2026: Habitual Residence Rules for Expats

If you sell a Costa del Sol property that is your vivienda habitual (habitual residence) and put the money into another main home, the capital gain can be fully or partly exempt from Spanish income tax under the reinvestment relief in the Ley 35/2006 del IRPF, but only if you are a tax resident and the home genuinely qualifies as your main residence. This matters when you buy, not just when you sell: the day you complete, you start building the occupancy record (minimum three continuous years) that the Agencia Tributaria will one day want to see. This article explains the three tests that decide whether your Costa del Sol home counts as your vivienda habitual in 2026, and how expats secure the exemption.

What is the main home (vivienda habitual) capital gains exemption in Spain?

It is a relief in the Spanish personal income tax (IRPF) that lets a tax resident avoid paying capital gains tax on the profit from selling their main home, provided the sale proceeds are reinvested into a new main home within a set window. If you reinvest the entire amount you received from the sale, 100% of the gain is exempt; if you reinvest only part, the exemption is proportional to the fraction reinvested. The rule lives in the Ley 35/2006 del IRPF and its regulation (Reglamento del IRPF, Real Decreto 439/2007).

Crucially this is a residents' relief. It is not the same as the non-resident route, where sellers face the 3% retention withheld at the notary and reclaim overpayments later, we cover that in our guide on the 3% retention and how non-residents reclaim it. To use the vivienda habitual exemption, you must be able to prove to the Agencia Tributaria that you lived in Spain as a tax resident and that the home was your base.

Who counts as a tax resident on the Costa del Sol in 2026?

You are a Spanish tax resident in a given year if you spend more than 183 days in Spain during the calendar year, or if your main economic interests or your spouse and dependent children are based here. This is the test in Article 9 of the Ley 35/2006 del IRPF. Residency is decided per calendar year, there is no half-year status, so a buyer who completes in, say, September will usually only become resident the following full year.

Being "resident" for immigration purposes (a TIE card, or an EU registration certificate) is not the same as tax residency, though in practice they overlap. If you spend most of the year in your Marbella or Estepona home and little elsewhere, you are almost certainly a Spanish tax resident and must file. New arrivals considering the flat-rate special regime should read our piece on the Beckham Law and who qualifies, note that Beckham Law taxpayers are taxed as non-residents and generally cannot use the vivienda habitual reinvestment relief.

What makes a property your vivienda habitual?

Three conditions must be met for the Agencia Tributaria to accept a Costa del Sol home as your habitual residence under the Reglamento del IRPF (RD 439/2007):

  • Occupancy within 12 months. You must move in within one year of completion (or of finishing building/renovation).
  • Three continuous years of residence. It must remain your main home for at least three years without interruption. If you sell earlier for a legitimate reason, a job move, marriage, separation, or circumstances that force the move, the tax office can still treat it as your vivienda habitual.
  • Genuine primary use. It is where you actually live day to day, evidenced by your empadronamiento at the town hall, utility consumption, your address on the Modelo 100 income tax return, and where your family is based.

A holiday home you visit for a few weeks does not qualify, however much you love it. If a Costa del Sol property is empty most of the year it is a second home, and you pay imputed rental income tax via Modelo 210 instead of enjoying a residents' exemption.

How does the reinvestment relief actually work?

If you sell your main home as a resident and buy another main home, the gain is exempt to the extent that you reinvest the sale proceeds. The reinvestment can happen in a window that runs from two years before to two years after the sale, so you may buy the new home first and sell the old one afterwards. You also keep the exemption if you build or substantially renovate the new main home, provided the works complete within the deadlines in the Reglamento del IRPF.

One common trap: if your old home still carries a mortgage, the "amount reinvested" is the net proceeds after cancelling that loan, not the gross price. So the proceeds you must plough into the new home are what actually reaches your bank account. You declare the reinvested gain as exempt on your annual Modelo 100 (IRPF declaration), the June deadline following the year of sale.

Capital gains outcome by buyer status on a Costa del Sol sale (2026, illustrative)
SituationWhoCapital gains on the main home gain
Tax resident, sells vivienda habitual, reinvests 100% in a new main homeResident expat relocating within the CostasFully exempt (Ley 35/2006)
Tax resident, reinvests only part of the proceedsResident downsizingExempt in proportion to the amount reinvested
Tax resident aged 65+ selling their vivienda habitualRetired residentFully exempt, no reinvestment needed
Non-resident selling a second homeOverseas ownerTaxable; 3% retained at notary, reclaim via Modelo 210

What is the over-65 exemption, and is it different?

Yes, and it is more generous. A tax resident aged 65 or over who sells their vivienda habitual pays no capital gains tax at all, with no obligation to reinvest the money. They can keep the cash, give it to their children, or buy a smaller place. This is a separate relief within the Ley 35/2006 del IRPF and it is one of the most valuable tools for older sellers. We go into it further, alongside reinvestment relief, in our dedicated guide on reinvestment relief and over-65 exemptions for Costa del Sol sellers.

There is also an over-65 relief on gains from selling other assets (not the main home) where the proceeds buy a life annuity, capped at €240,000, but that is a different mechanism and the paperwork is strict.

Why does this matter when you are buying, not selling?

Because the clock starts on your completion day. To one day claim the exemption on this home, you need a clean record showing it was genuinely your main residence for at least three years. Practically, that means from the moment you complete on your Costa del Sol purchase you should:

  • Register on the padrón at the local town hall (empadronamiento) soon after moving in.
  • Put utilities (water, electricity, internet) in your name and actually use them, meter readings tell a story.
  • File your Spanish resident income tax return (Modelo 100) once resident, declaring this address.
  • Keep every purchase-cost receipt, ITP or IVA, notary, registry, lawyer, because these raise your acquisition cost and shrink any future taxable gain.

Those same receipts matter whichever home you eventually sell; our list of deductible expenses to keep applies across all four Costas. And if your plan is simply to sell one Spanish home to fund another, see our guide to capital gains deferral when moving between the four Costas.

What does it cost to buy the main home in the first place?

The exemption is about the eventual sale, but the purchase sets your acquisition cost. On the Costa del Sol (Andalucía) a resale pays ITP transfer tax of 7%, the lowest of our four regions, on the higher of the price paid or the cadastral valor de referencia set by the Catastro. A new build pays 10% IVA plus 1.2% AJD stamp duty in Andalucía. Add notary (~0.2-0.5%), land registry (~0.1-0.25%), a lawyer (~1% + IVA) and a gestoría (~€300). As a rule of thumb, budget around 10-13% on top of a resale price and 12-15% on a new build, with Andalucía at the lower end of both.

For the full regional picture see our breakdown of resale ITP rates across the Costa Blanca, Cálida, del Sol and Almería. By comparison, a Costa Blanca resale (C. Valenciana) pays 9% from 1 June 2026, the Costa Cálida (Murcia) pays 7.75%, and the Costa Almería (Andalucía) matches the Costa del Sol at 7%.

What we see in our own listings

Across Mediter's current Costa del Sol stock, prices span a wide range, from apartments suited to a modest main-home budget up to substantial villas. That spread matters for the exemption: if you downsize from a larger villa to a smaller apartment and do not reinvest the full proceeds, your exemption is only proportional to the amount you plough back in. Buyers planning to make a Costa del Sol home their genuine primary residence should model the figures before committing, because whether a property is a main home or a second home changes the entire tax treatment on a future sale.

Common mistakes expats make with the vivienda habitual exemption

  • Assuming a holiday home qualifies. It must be your genuine main residence, backed by real evidence.
  • Selling before three years without a valid reason. Early sales can lose the relief unless a recognised circumstance forced the move.
  • Forgetting the mortgage reduces reinvestable proceeds. A loan being repaid shrinks the amount that counts as reinvested.
  • Mixing up tax residency with an immigration card. Only tax residency unlocks the IRPF relief.
  • Trusting an AI chatbot for a binding answer. We regularly correct wrong AI answers, see ChatGPT is not your Spanish property lawyer. Always confirm with a Spanish tax adviser before you sign.

Thorough due diligence before you buy avoids most of these; our pre-purchase legal due diligence checklist is a good starting point for any of the four Costas.

Frequently Asked Questions

Do I have to reinvest the whole sale price to avoid capital gains tax on my Costa del Sol main home?

To be fully exempt you must reinvest the entire net proceeds (after cancelling any mortgage) into a new main home within the two-year window set by the Reglamento del IRPF. Reinvest only part, and the exemption applies proportionally to the fraction you reinvest.

How long must I live in my home for it to count as my vivienda habitual?

At least three continuous years, having moved in within 12 months of completion. Selling earlier for a recognised reason, a job relocation, marriage or separation, can still preserve the status under the Reglamento del IRPF (RD 439/2007).

Can a non-resident use the main home exemption?

No. The vivienda habitual reinvestment relief is only for Spanish tax residents filing Modelo 100. Non-residents selling a Costa del Sol home face the standard capital gains rules with the 3% retention at the notary, reclaimed via Modelo 210 if overpaid.

Is the over-65 exemption really unconditional?

For the main home, yes, a resident aged 65 or over who sells their vivienda habitual pays no capital gains tax and does not need to reinvest, under the Ley 35/2006 del IRPF. The home must still genuinely be their habitual residence.

What proves my Costa del Sol home is my main residence?

Your empadronamiento at the town hall, utility bills and consumption in your name, the address on your resident tax return, and your family's presence there. The Agencia Tributaria looks at the whole picture, not a single document.

Does the Beckham Law affect the exemption?

Yes. Taxpayers under the special expat regime (Beckham Law) are taxed as non-residents and generally cannot claim the vivienda habitual reinvestment relief, so weigh the regimes carefully before applying.

Thinking of making the Costa del Sol your home?

Whether a Costa del Sol property becomes your genuine main residence or a holiday base changes everything about your future tax bill, and the decisions you make on completion day matter years later. The team at Mediter Real Estate helps international buyers find the right home across the Costa del Sol, Costa Blanca, Costa Cálida and Costa Almería, and works alongside trusted local lawyers and tax advisers. Contact Mediter Real Estate today to talk through your plans and view property that fits your residency goals.

← All articles