United States · Individuals

Capital Gains on a Home Sale: The 2-of-5-Year Exclusion Rules

You can exclude up to $250,000 of gain on your main home ($500,000 for a married couple filing jointly) if you owned and lived in it for 2 of the last 5 years and excluded no other home's gain within 2 years. Selling sooner for work, health or an unforeseen event allows part. Depreciation, a share for earlier rental use, and gain above the limit are taxable; report any Form 1099-S.

Di Lu, CPA
Di Lu, CPAUS and Canadian CPA

Have a question about your situation?

Free · 10 minutes · Phone call

English & Chinese

Book a callChoose a time that works for you

Tax year 2026 · Last updated  · Published by Cloud Accounting under standing professional approval

Who this is for

  • US taxpayers selling the home they live in, or used to live in
  • Owners who rented the home, sold early, married, or served away on orders

Not covered here

  • A property that was only ever a rental, and 1031 exchanges
  • A home outside the US, and Canada's principal residence exemption
  • State income tax on the sale

Do I pay capital gains when I sell my house?

You can exclude gain on selling your main home up to $250,000, or $500,000 for a married couple filing jointly, when the three tests below are met and neither bar below applies (26 U.S.C. 121; Publication 523). Gain is the sale price minus selling costs and your adjusted basis: generally what you paid, plus improvements, minus any depreciation. Upkeep such as painting or fixing leaks is not an improvement.

TestWhat it requires
OwnershipYou owned the home for at least 24 months in the 5 years before the sale
UseYou lived in it as your main home for at least 24 months in those 5 years
Look-backYou did not exclude gain on another home in the 2 years before the sale

Two automatic bars apply: a home acquired in a 1031 exchange within the past 5 years, and a seller subject to the expatriate tax (Publication 523). A loss on selling a main home is not deductible. The law sets no age test and does not require buying another home, and the exclusion can be used again once 2 years have passed (26 U.S.C. 121(a) and (b)(3)).

A home sale is not simple when the home was ever rented or used for a business, when you sell before 2 years, when spouses did not both live there, when title is in an LLC or trust, or after a divorce or a death. Those cases can leave part of the gain taxable.

Gather the closing statements from the purchase and the sale, receipts for improvements, the dates you moved in and out, any depreciation you claimed, and any Form 1099-S.

What tax do I pay on gain above the exclusion?

Taxable gain on a home owned more than one year is long-term capital gain, taxed at 0%, 15% or 20% depending on income; gain from depreciation is taxed at up to 25% (Topic 409). Taxable gain can also bring the 3.8% net investment income tax when modified adjusted gross income is above $200,000 ($250,000 joint); excluded gain cannot (IRS).

How is the 2 out of 5 year rule counted?

The 5 years run back from the date of sale, and each 2-year test is met with 24 full months or 730 days, added up in any number of pieces (26 CFR 1.121-1(c)). The date of sale is the date in box 1 of Form 1099-S; without that form, it is the earlier of the day title passed or the day the buyer took on the burdens and benefits of ownership (Publication 523).

  • Ownership and use need not overlap. Years you rented the home as a tenant before buying it count toward the use test, if both tests are met within the 5 years (26 CFR 1.121-1(c); Topic 701).
  • Short absences count as use. A vacation or seasonal absence counts as time lived there, even if the home was rented meanwhile. A year-long sabbatical abroad does not, in the regulation's own example.
  • Care facility time can count. An owner who becomes unable to care for themselves, and lived in the home for at least 12 months of the 5 years, is treated as living there while in a state-licensed care facility such as a nursing home (26 U.S.C. 121(d)(7)).
  • A replaced home can count. If an earlier home was destroyed or condemned and you put off that gain by buying this one, time in the earlier home counts (26 U.S.C. 121(d)(5)).
  • Some title holders count as you. A grantor trust you are treated as owning, or a single-owner entity disregarded for tax, counts as you (26 CFR 1.121-1(c)(3)). For other entities, see a home in an LLC.

2 out of 5 year rule after renting it out: how much can I still exclude?

Rental after your last day living there, inside the 5-year window, does not cut the exclusion. Rental or other time from January 1, 2009 when neither you nor your spouse or former spouse lived there as a main home does, if it comes before the last day either of you lived there, whether before you moved in or between two stays: that share of the gain stays taxable (26 U.S.C. 121(b)(5)). Sell more than 3 years after moving out and you no longer lived there 2 of the 5 years, so the full exclusion is lost; a partial one needs a work, health or unforeseen reason (below).

SituationEffect on the exclusion
Lived there at least 2 years, then rented it out, sold within 3 years of moving outThe rental does not reduce the exclusion if the other tests are met; depreciation is taxed
Rented it out or used it as a second home before moving in, or between two staysGain is split by time; the non-home share is taxable
Away temporarily for a job, health or another unforeseen reason, up to 2 years in totalNot counted as non-home use
Away on qualified official extended duty, up to 10 yearsNot counted as non-home use

The taxable share is the days from January 1, 2009 when neither of you lived there, before the last day either of you did, divided by all days you owned the home (Publication 523, Worksheet 3). Gain equal to depreciation is taken out first and taxed separately.

Depreciation for periods after May 6, 1997 is never excluded, and it counts whether you claimed it or only could have claimed it (26 U.S.C. 121(d)(6); Publication 523). An owner who rented for years without depreciating still has that amount taxed. For depreciation, recapture detail and exchanges, see rental property taxes.

Sold my house before 2 years: is there a partial exclusion?

A seller who misses the 2-year tests, or sells within 2 years of an earlier excluded sale, can still exclude part of the gain when the main reason for the sale is a work move, health, or an unforeseen event (26 U.S.C. 121(c)). The event can happen to you, your spouse, a co-owner, or anyone else who lived in the home as their residence (Publication 523). Each safe harbor needs the job change or event to happen while you own and live in the home.

ReasonTreated as qualifying (safe harbor) when
WorkThe new workplace is at least 50 miles farther from the home than the old one, or at least 50 miles from the home if there was no old one
HealthA doctor recommends the move for a health reason, including to give or get care for an ill or injured family member. A move for such care without that recommendation must be shown to be the main reason (below); Publication 523 is looser, but the regulation governs
Unforeseen eventThe home is destroyed, condemned or damaged by a natural or man-made disaster or terrorism; or a death, divorce or legal separation, multiple births from one pregnancy, eligibility for unemployment compensation, or a job change that leaves the household unable to pay basic living costs

Outside these safe harbors, the facts must show the event was the main reason. Factors that weigh in favor: it arose while you owned and lived there, could not reasonably have been foreseen when you bought, and came shortly before the sale (26 CFR 1.121-3). Wanting a bigger home, a pay raise, or a rise in the home's value does not qualify, and a move that only helps general health is not a health reason.

The partial limit is the full limit times a fraction: the shortest of your time owned and your time lived there, both within the 5 years, and the time since your last excluded sale, over 24 months or 730 days (26 CFR 1.121-3(g)). On a joint return that misses the joint test, each spouse's amount is worked out this way and added.

Home sale exclusion for married filing jointly: who gets the joint amount?

A married couple filing jointly gets up to $500,000 only when either spouse meets the ownership test, both spouses meet the use test, and neither excluded gain on another home within 2 years (26 U.S.C. 121(b)(2)). Otherwise the couple's limit is the sum of what each spouse would get if unmarried, with each treated as owning the home for as long as either spouse did.

SituationLimit
Both lived there 2 of the 5 years, joint returnUp to $500,000
Only one spouse lived there 2 of the 5 years, joint returnUp to $250,000. The other spouse adds a partial amount only if the sale is for a work, health or unforeseen reason (above); otherwise nothing
Each spouse sells a home they lived in before marryingUp to $250,000 on each home; one spouse cannot use the other's unused amount
Co-owners filing separate returns, or unmarried co-ownersEach up to $250,000 on their own share of the gain

If one spouse is a nonresident alien, a joint return needs a choice to treat that spouse as a US resident; see married to a nonresident.

Rules for spouses who part ways or lose a spouse (26 U.S.C. 121(d); 26 CFR 1.121-4):

  • Separated or divorced: an owner whose spouse or former spouse is allowed to live in the home under a divorce or separation instrument is treated as living there too.
  • Home received from a spouse or ex-spouse: you count the time they owned it, but must meet the use test yourself.
  • Surviving spouse: an unremarried surviving spouse counts the late spouse's ownership and use, and can use the joint limit if the home is sold within 2 years of the death and the joint tests were met just before it.

I own two homes: which one counts as my main home?

A person has only one main home at a time, and only that home qualifies (Publication 523). When you live in two homes, the one you live in most of the year is ordinarily your main home (26 CFR 1.121-1(b)(2)).

Other facts point the same way: the address on your tax returns, driver's license, car and voter registration; where you work, bank and get mail; and where your family lives. A home you switched to in different years can qualify in turn, but the 2-year look-back stops you excluding gain on both within 2 years. Gain on a home that fails the tests is taxable and can count toward net investment income tax.

I live in one unit of a duplex or use part of the home for business: how is the gain split?

The answer turns on whether the business or rental space is inside your living area or a separate unit (26 CFR 1.121-1(e)).

SpaceTreatment
Inside the dwelling (a home office, a rented spare room)No split; the whole gain can qualify, minus depreciation for that space
A separate unit or building (the other half of a duplex, a store below an apartment, a barn)Basis and sale price are split; gain on the separate part is taxable and goes on Form 4797
A separate part you later lived in as your home for 2 of the 5 yearsCan qualify, but its earlier depreciation is taxed and its non-home years since January 1, 2009 reduce the exclusion

Split the price and basis the same way you split them for depreciation, or by floor area if you never depreciated (Publication 523).

Military or Foreign Service: can the five-year window be stretched?

Yes. A member of the uniformed services or the Foreign Service, an employee of the intelligence community, or a Peace Corps employee or volunteer serving abroad can choose to suspend the 5-year window while they or their spouse are on qualified official extended duty, for up to 10 years (26 U.S.C. 121(d)(9) and (12)).

Qualified official extended duty means orders for more than 90 days or for an indefinite period, at a duty station at least 50 miles from the home, or living in government quarters under government orders (Topic 701). The choice covers one property at a time, can be revoked at any time, and is made by filing the return for the year of sale and excluding the gain (Publication 523).

Used the exclusion in the last two years, or got the home in a 1031 exchange: can I still exclude gain?

Each can block the exclusion. A seller who excluded gain on another home in the 2 years before this sale cannot exclude again, unless a work, health or unforeseen reason allows a partial exclusion (26 U.S.C. 121(b)(3)).

A home acquired in a 1031 exchange cannot use the exclusion if sold within 5 years of that exchange. The same bar applies to someone whose basis comes from the person who made the exchange, such as a child given the home (26 U.S.C. 121(d)(10); Publication 523). See rental property taxes for exchanges.

Home received as a gift, by deed from a relative, or after a spouse died: what basis and which years count?

The basis depends on how the home came to you, and the years that count depend on who gave it (Publication 523).

How you got the homeStarting basisEarlier owner's time
Gift, including a deed from a parentUsually the giver's adjusted basis; special rules if the value was below that, or if gift tax was paidPublication 523 lists no rule counting a giver's years, other than a spouse's or former spouse's
InheritanceUsually the home's value at the date of deathPublication 523 lists no rule counting the person's years, other than a late spouse's
From a spouse or in a divorceUsually the spouse's adjusted basisTheir ownership counts; you must meet the use test yourself
Joint home after a spouse's deathHalf the old basis plus half the value at death; in community property states, usually the full value at deathThe late spouse's ownership and use count if you have not remarried

Publication 523 counts an earlier owner's time only for a spouse, former spouse or late spouse; with a home from a parent or an estate, have the count checked before relying on the earlier owner's years. Adding a child to the title is a gift; see gift tax returns. An heir or executor selling a parent's home should see estate and final returns.

Got a 1099-S for my home sale: do I have to report it?

Yes. A Form 1099-S means the sale goes on Form 8949 and Schedule D even when all the gain is excluded (Topic 701). Without a 1099-S, you report only if part of the gain is taxable, or if you choose to be taxed now and keep the exclusion for a later sale (Publication 523). You can make or undo that choice within 3 years of the return's due date, not counting extensions (26 CFR 1.121-4(g)).

  1. On Form 8949, report the sale price and basis as if no exclusion applied, using Part II if you owned the home more than one year.
  2. Enter code H in column (f) and the excluded gain as a negative number in column (g). If selling costs are not on the 1099-S, add them to that negative amount and enter code EH (Instructions for Form 8949).
  3. Report gain from depreciation, and gain on any separate business or rental part, on Form 4797.
  4. A loss with a 1099-S is still reported, with code L, so that it nets to zero (Instructions for Schedule D).

A home bought with a loan from tax-exempt mortgage bonds or with a mortgage credit certificate may owe recapture on Form 8828 even when the gain is excluded. Keep purchase and improvement records until 3 years after the due date of the return for the year of sale (Publication 523).

Example

These examples are illustrative and use US dollars. Selling costs are left out to keep the numbers round.

Rented after moving out

A single owner buys a home for US$300,000 and lives in it for five years. She then moves out and rents it for three years, claiming US$20,000 of depreciation, and sells for US$520,000.

  • Years 1 to 5: main home.
  • Years 6 to 8: rental; the 5 years before the sale include her last 2 years living there.
  • Sale: adjusted basis is US$280,000 (US$300,000 minus US$20,000), so the gain is US$240,000.

The rental came after she moved out, so it does not reduce the exclusion. The US$20,000 equal to depreciation is taxed; the other US$220,000 is under the US$250,000 limit and is excluded.

Job move after 14 months

A single owner whose job is 10 miles from home takes a new job 300 miles away while living there, and sells after owning and living in the home for 14 months, with a US$40,000 gain. The work move meets the 50-mile safe harbor. The partial limit is 14/24 of US$250,000, about US$145,800, so the whole US$40,000 gain is excluded.

Two homes after marriage

Each spouse owned and lived in a home before marrying. They move into hers, and he sells his while he still has 2 of the last 5 years of living there, with a US$180,000 gain. On their joint return, his home's limit is US$250,000, not US$500,000: she never lived there, and moving in together is not a work, health or unforeseen reason, so her share is zero. His US$180,000 gain is fully excluded.

Individual tax returns

Selling a home you once rented out?

If the home was rented, used for business, held in a trust, sold within 2 years, or sold after a divorce or a death, talk to us before you file. We go over your dates and records and scope the sale reporting we can prepare, not a final gain figure.

  • Closing statements from the purchase and the sale, and receipts for improvements.
  • The dates you moved in and out, any depreciation claimed, and any Form 1099-S.

Free · 10 minutes

Discuss your home sale

Individual tax returns

Different for you?

Figures on this page

FigureValueSource
Home sale gain exclusion, single
Maximum gain excluded on the sale of a main home owned and used as a main home for 2 of the 5 years before sale; not indexed
$250,000IRS: Publication 523, Selling Your Home
Checked
Home sale gain exclusion, married filing jointly
Maximum gain excluded on a joint return that meets the joint ownership and use rules; not indexed
$500,000IRS: Publication 523, Selling Your Home
Checked
Holding period that makes a US capital gain or loss long-term
One year or less is short-term; the holding period counts from the day after acquisition up to and including the day of disposition; exceptions apply for some property
More than one yearIRS: Topic no. 409, Capital gains and losses
Checked
Lowest federal rate on most net long-term capital gain
Applies to the portion within the zero-rate taxable-income band.
0%IRS: Revenue Procedure 2025-32, section 4.03
Checked
Middle federal rate on most net long-term capital gain
Applies above the zero-rate band through the maximum middle-rate taxable-income amount.
15%IRS: Revenue Procedure 2025-32, section 4.03
Checked
Top federal rate on most net long-term capital gain
Applies above the upper 15% capital-gain taxable-income threshold; special gain categories can have different rates
20%IRS: Topic 409, Capital gains and losses
Checked
Maximum tax rate on unrecaptured section 1250 gain
Applies to the qualifying depreciation-related portion of gain from section 1250 real property
25%IRS: Topic 409, Capital Gains and Losses
Checked
Net investment income tax rate
Rate on the lesser of net investment income or modified adjusted gross income above the filing-status threshold
3.8%IRS: Net Investment Income Tax
Checked
Net Investment Income Tax threshold, single or head of household
Modified adjusted gross income; not indexed for inflation
$200,000IRS: Questions and answers on the Net Investment Income Tax
Checked
Net Investment Income Tax threshold, married filing jointly
Modified adjusted gross income; not indexed for inflation
$250,000IRS: Questions and answers on the Net Investment Income Tax
Checked
Date from which non-home use reduces the home-sale exclusion
Periods before this date are not periods of nonqualified use under section 121(b)(5); applies to sales after December 31, 2008
January 1, 200926 U.S.C. 121(b)(5)(C)
Checked
Home-sale exclusion cutoff for rental depreciation
Gain attributable to depreciation allowed or allowable for periods after this date cannot be excluded under section 121
May 6, 1997IRS: Publication 523
Checked

Primary sources

About this guide

Published by Cloud Accounting under standing professional approval. This version has no separately recorded personal review. It explains general rules for the tax year shown. It is not advice for your situation.

Changes

  • : First published.
Di Lu, CPA
Di Lu, CPAUS and Canadian CPA

Ready to talk through your next step?

Free · 10 minutes · Phone call

English & Chinese

A first call to discuss your needs and how we can help.

Book a callChoose a time that works for you

Book a consultation

Free · 10 minutes

By booking, you agree to our privacy policy. If an ad brought you here, we tell that ad platform when you book, and may tell it when you spend time on a page, tap our phone number or pick a time. We never share your name, email or phone. Privacy policy

Calendar not loading? Book a consultation