Capital gains and losses
What they are, when they arise, how they are calculated and what exemptions exist. Includes transfer of main home, shares, investment funds and virtual currencies.
F1 From transfers (savings tax base)
[1624]et seq. — Gains from the transfer of other assets
F2 Aid and subsidies (general tax base)
[0266]Spanish Historical Heritage aid[0279]First-establishment aid for young farmers[0299]–[0300]Main-home subsidies[0301]Aid for IBI, boilers, energy efficiency[0303]Public rental aid[0304]Regional/local subsidies and other vouchers[0323]Youth Cultural Voucher[0356]€200 aid for low income levels[0362]Thermal Social Voucher
Capital gains and losses are changes in the value of your assets that become apparent when you change the composition of your estate: you sell a flat, transfer shares, inherit assets... If you received more than you paid, there is a gain; if you received less, there is a loss.
🔵 Legislation: Art. 33 et seq. Personal Income Tax Law
When does a capital gain or loss arise?
Three conditions must be met for a capital gain or loss to exist:
- There must be an alteration in the composition of the estate (sale, gift, barter, allocation with excess, etc.).
- That alteration must generate a change in its value (difference between what you paid and what you receive).
- The Law must not classify it as another type of income (employment, capital, economic activity).
Operations that do NOT generate a gain or loss
- Division of jointly owned property among co-owners (without excess allocation)
- Dissolution of the marital community of property or termination of the participation regime
- Dissolution of jointly owned assets or separation of co-owners
- Termination of the separation of property matrimonial regime by legal imposition or court order
- Transfers on death ("mortis causa donation" or succession pacts)
If in the dissolution of jointly owned assets a co-owner receives more than their share (excess allocation) and that difference has a positive value, a capital gain does arise for the person receiving the excess.
Which gains are not taxed? Main exemptions
A. Transfer of main home by persons over 65
ℹ️ Are you over 65? A dedicated guide covers pensions, home-sale exemption, reinvestment in life annuities (€240,000), reverse mortgage and age-increased minimums: IRPF manual for taxpayers over 65.
Gains from the transfer of the main home are fully exempt when the taxpayer is over 65 or is in a situation of severe or major dependency.
B. Reinvestment in main home
Gains from the transfer of the taxpayer's main home are exempt, provided the full amount obtained from the transfer is reinvested in the acquisition of a new main home within the following time limits:
- 2 years before or after the transfer
- If the price is deferred, reinvestment may be made progressively as the instalments are received
If only part is reinvested, only that proportional part is exempt.
The exemption does not apply when the property transferred does not represent full ownership (for example, if only the bare ownership or usufruct is transferred).
C. Reinvestment in life annuities (persons over 65)
Gains from the transfer of any asset (not just housing) are exempt if the amount is used to set up an insured life annuity, provided:
- The taxpayer is over 65
- The annuity is set up within a maximum period of 6 months
- The maximum amount of the life annuity to which the exemption applies is €240,000 (cumulative over the taxpayer's lifetime)
D. Compensation for civil liability and personal injury
Exempt to the amount legally or judicially recognised.
E. Lottery and betting prizes
SELAE, Red Cross and ONCE prizes are exempt up to €40,000 per ticket, coupon or bet. The excess is taxable at a special 20% rate.
F. Donations to entities under Law 49/2002
Gains arising from the donation of assets to non-profit entities covered by Law 49/2002 are exempt for the donor.
G. Mortgage-to-key of the main home
The capital gain arising from handing over the main home in lieu of payment to cancel mortgage-secured debts is exempt, when the debtor does not have other sufficient assets or rights to satisfy the full debt.
Gains and losses that are not counted as such
These operations occur but the Law does not recognise them for tax purposes (they are not taxed, but they also do not offset gains):
- Gambling losses
- Losses from transfers of assets where the same assets are reacquired within one year (shares or homogeneous securities); for real estate, the period is two years
How a capital gain or loss is calculated
General rule
Net transfer value
- (+) Transfer value — actual price received, or market value if higher
- (−) Transfer expenses and taxes — IIVTNU, notary, land registry, agency, etc.
- = Net transfer value
Net acquisition value
- (+) Acquisition price — or value declared for Inheritance and Gift Tax
- (+) Acquisition expenses and taxes — notary, land registry, ITP/AJD, VAT, etc.
- (+) Investments and improvements made to the asset
- (−) Fiscally deductible depreciation — real estate that has generated income
- = Net acquisition value
Gain or loss = Net transfer value − Net acquisition value
Transfers by way of gift (donations, inheritances)
- Recipient: the acquisition value is the amount declared for Inheritance and Gift Tax, up to market value.
- Donor: a capital gain or loss arises from the difference between the market value of the donated asset and its acquisition value, unless exempted.
🧮 Worked example
Worked example: how much you gain when selling a property
Carlos sells in 2025 a property that is not his main home, bought in 2010. Here is how the gain is worked out step by step:
- 2025 sale: €200,000, with €8,000 in costs (municipal capital-gains tax, notary, agency)
- 2010 purchase: €140,000, with €12,000 in costs and taxes (transfer tax, notary, registry)
| Item | Amount |
|---|---|
| Sale price (2025) | €200,000.00 |
| (−) Transfer costs | − €8,000.00 |
| (=) Net transfer value | €192,000.00 |
| Purchase price (2010) | €140,000.00 |
| (+) Purchase costs and taxes | + €12,000.00 |
| (=) Net acquisition value | €152,000.00 |
| (=) Capital gain (192,000 − 152,000) | €40,000.00 |
Sale price (2025)
Amount €200,000.00
(−) Transfer costs
Amount − €8,000.00
(=) Net transfer value
Amount €192,000.00
Purchase price (2010)
Amount €140,000.00
(+) Purchase costs and taxes
Amount + €12,000.00
(=) Net acquisition value
Amount €152,000.00
(=) Capital gain (192,000 − 152,000)
Amount €40,000.00
🧮 Where this gain is taxed: the €40,000 is a gain from a transfer, so it goes into the savings tax base (not the general one), where it is taxed in bands. If in the same year you had savings-base capital losses —for example, from selling shares at a loss—, they would first be offset against this gain. And if the property were your main home and you reinvested the proceeds in another one, the gain could be exempt.
Special valuation rules by type of asset
Shares listed on the stock exchange
| Item | Rule |
|---|---|
| Transfer value | Quoted price on the transfer date, or agreed price if higher |
| Acquisition value | Purchase price including expenses (less income from sale of subscription rights before 2017) |
| Identification criterion | FIFO: the shares acquired first are deemed to be sold first |
| Subscription rights | From 1/1/2017: capital gain in the year of transfer |
Transfer value
Rule Quoted price on the transfer date, or agreed price if higher
Acquisition value
Rule Purchase price including expenses (less income from sale of subscription rights before 2017)
Identification criterion
Rule FIFO: the shares acquired first are deemed to be sold first
Subscription rights
Rule From 1/1/2017: capital gain in the year of transfer
Unlisted shares
The transfer value may not be less than the greater of:
- The value of the equity according to the last balance sheet closed before the Personal Income Tax accrual date
- The result of capitalising at 20% the average of profits for the last three tax years
Investment funds
| Item | Rule |
|---|---|
| Transfer value | Net asset value on the redemption date (or net asset value if there is no liquidation value) |
| Transfer between funds | No tax at the time of transfer: the new units retain the acquisition date and value of the original ones |
| Exception to deferral | Does not apply to ETFs (exchange-traded funds) or where the taxpayer receives the money |
Transfer value
Rule Net asset value on the redemption date (or net asset value if there is no liquidation value)
Transfer between funds
Rule No tax at the time of transfer: the new units retain the acquisition date and value of the original ones
Exception to deferral
Rule Does not apply to ETFs (exchange-traded funds) or where the taxpayer receives the money
Virtual currencies (cryptocurrencies)
Cryptocurrencies are treated as intangible assets for tax purposes. They generate a capital gain or loss when:
- Sold in exchange for euros or other legal tender
- Exchanged for a different cryptocurrency (barter transaction, taxable at that point)
The gain is calculated as the difference between the transfer value (euros received or market value) and the acquisition value in euros. The identification criterion is also FIFO.
Cryptocurrency gains and losses are savings income (included in the savings taxable base).
Real estate
- The acquisition value includes the purchase price, inherent expenses and taxes (ITP/AJD, notary, land registry, agency fees) and investments in improvements.
- Depreciation is deducted if the property was rented (3% per year on the greater of the construction cost or the cadastral value of the construction, with the minimum of depreciation actually deducted).
- The transfer value may not be less than the cadastral reference value for ITP/AJD purposes.
Non-monetary contributions to companies
The transfer value is the greater of:
- Nominal value of the shares or interests received (plus issue premium)
- Listed value of the securities received
- Market value of the asset or right contributed
Reduction coefficients (transitional regime)
For assets acquired before 31 December 1994 and transferred before reaching a cumulative transfer value of €400,000 (since 2015), part of the gain may be reduced using abatement coefficients:
- Only the gain generated before 20 January 2006 is reduced
- The coefficients depend on the type of asset and the years of ownership as at 31/12/1996
- For real estate: 11.11% per year of ownership; for securities and other assets: 25% and 14.28% per year respectively
Temporal imputation: in which year is it declared?
The general rule is that the gain or loss is attributed to the year in which the alteration in the estate occurs (normally, when the contract is signed or the asset is delivered).
Key exceptions
- Instalment or deferred payment transactions: you may opt to attribute proportionally as the instalments are received.
- Public aid: attributed in the year of receipt.
- Losses from bad debts: attributed when insolvency is established (insolvency proceedings, or more than one year since the default if conditions are met).
Integration and compensation in the taxable base
Capital gains and losses are divided into two groups:
| Type | Where included |
|---|---|
| Derived from transfers with a generation period of any duration (including those under 1 year) | Savings taxable base |
| Not derived from transfers (gaming prizes, subsidies, asset incorporations, etc.) | General taxable base |
Derived from transfers with a generation period of any duration (including those under 1 year)
Where included Savings taxable base
Not derived from transfers (gaming prizes, subsidies, asset incorporations, etc.)
Where included General taxable base
Compensation of losses
- Savings losses first offset savings gains from the same year.
- The negative balance may be offset against the positive balance of investment income up to 25% of that positive balance.
- The remaining negative balance may be carried forward to the 4 following tax years.
Relevant special cases
Exit tax (change of residence)
If you lose your taxpayer status by transferring your habitual residence abroad and hold shares or interests with a market value exceeding €4,000,000 (or with a shareholding exceeding 25% in entities with a market value over €1,000,000), you must pay tax on the "latent" gain even though you have not sold.
You may request a deferral of payment if the relocation is for employment reasons or is temporary.
Transfer of main home with reinvestment: example
A married couple aged 70 and 68 sell their main home in 2025 for €250,000. They acquired it in 1980 for €60,000 (including expenses). Since both are over 65, the capital gain is fully exempt, regardless of whether or not they reinvest the amount.
Transfer between investment funds
If you hold units in a fund and transfer them to another without receiving any money, you are not taxed at that point. The new units retain the seniority and acquisition value of the original ones, so taxation is deferred until the final redemption.
Applicable legislation
Verbatim text of the key provisions (Spanish Income Tax Law 35/2006, BOE-A-2006-20764 consolidated) — quoted in Spanish because that is the official BOE wording:
Art. 33.1 PIT Law — Definition of a capital gain or loss
«Son ganancias y pérdidas patrimoniales las variaciones en el valor del patrimonio del contribuyente que se pongan de manifiesto con ocasión de cualquier alteración en la composición de aquél, salvo que por esta Ley se califiquen como rendimientos.»
Art. 34.1 PIT Law — Amount of the gain or loss (general rule)
«El importe de las ganancias o pérdidas patrimoniales será: a) En el supuesto de transmisión onerosa o lucrativa, la diferencia entre los valores de adquisición y transmisión de los elementos patrimoniales. b) En los demás supuestos, el valor de mercado de los elementos patrimoniales o partes proporcionales, en su caso.»
Art. 35 PIT Law — Transfers for valuable consideration (acquisition and transfer value)
«El valor de adquisición estará formado por la suma de: a) El importe real por el que dicha adquisición se hubiera efectuado. b) El coste de las inversiones y mejoras efectuadas en los bienes adquiridos y los gastos y tributos inherentes a la adquisición, excluidos los intereses, que hubieran sido satisfechos por el adquirente. […] El valor de transmisión será el importe real por el que la enajenación se hubiese efectuado. De este valor se deducirán los gastos y tributos a que se refiere la letra b) del apartado 1 en cuanto resulten satisfechos por el transmitente. Por importe real del valor de enajenación se tomará el efectivamente satisfecho, siempre que no resulte inferior al normal de mercado, en cuyo caso prevalecerá éste.»
Art. 38 PIT Law — Gains excluded from taxation through reinvestment
«Podrán excluirse de gravamen las ganancias patrimoniales obtenidas por la transmisión de la vivienda habitual del contribuyente, siempre que el importe total obtenido por la transmisión se reinvierta en la adquisición de una nueva vivienda habitual en las condiciones que reglamentariamente se determinen. […] Podrán excluirse de gravamen las ganancias patrimoniales que se pongan de manifiesto con ocasión de la transmisión de elementos patrimoniales por contribuyentes mayores de 65 años, siempre que el importe total obtenido por la transmisión se destine en el plazo de seis meses a constituir una renta vitalicia asegurada a su favor, en las condiciones que reglamentariamente se determinen. La cantidad máxima total que a tal efecto podrá destinarse a constituir rentas vitalicias será de 240.000 euros.»
Other references:
- Art. 33.2 and 33.3 Personal Income Tax Law — Cases where there is no change in net worth or no gain/loss is computed (division of jointly-owned property, dissolution of community property, capital reductions)
- Art. 36 Personal Income Tax Law — Transfers for no consideration: value under Inheritance and Gift Tax rules
- Art. 37 Personal Income Tax Law — Specific valuation rules (listed and unlisted shares, investment funds, non-cash contributions)
- Art. 39 Personal Income Tax Law — Unjustified capital gains
- Art. 49 Personal Income Tax Law — Aggregation and offsetting within the savings tax base
- Art. 95 bis Personal Income Tax Law — Exit tax: gains on change of residence
- Transitional Provision 9 Personal Income Tax Law — Reduction coefficients (transitional regime) for assets acquired before 31 December 1994
- Art. 14.2.d) Personal Income Tax Law — Time allocation of instalment or deferred-price transactions