Skip to main content
RealCostIQ

Selling a home · tax scenarios

Capital Gains Tax on a Home Sale: 7 Scenarios That Change the Answer

"Live in it 2 of the last 5 years, exclude up to $500k" is the headline rule — and it's where our capital gains tax calculator does the arithmetic. This guide covers what that headline rule doesn't: the seven situations — divorce, a spouse's death, an inheritance, a second home, a former rental, military orders, and your state's own tax — that change the answer before the arithmetic even starts.

By RealCost Editorial TeamReviewed by RealCost Editorial TeamPublished September 3, 2026 with 2026 IRS figures

Most sellers of a primary residence owe nothing — the Section 121 exclusion covers up to $250,000 of gain single, $500,000 joint. But "did you live there 2 of the last 5 years" is the wrong question for a divorce, a death, an inheritance, a former rental, a second home, or military orders — each has its own rule, sourced below, that overrides or modifies the headline test.

The seven scenarios, at a glance

ScenarioWhat changes
Divorce, ex-spouse stayedTheir occupancy under the decree can still count as your use
Spouse died, selling within 2 yearsKeep the full $500,000 exclusion, not $250,000
Inherited the homeBasis resets to date-of-death value — often little or no gain
Second home / vacation propertyNo exclusion at all; full gain is taxable
Former rental, now primary againDepreciation recapture plus a post-2008 nonqualified-use carve-out
Military / Foreign Service duty5-year look-back can extend up to 15 years
Your state9 states charge no capital gains tax; most others tax the gain as ordinary income

Scenario 1 · Divorce or separation

You divorced and your ex-spouse kept living in the house

The Section 121 use test asks whether you lived in the home for 24 of the last 60 months — which looks fatal if you moved out at the divorce and your ex-spouse stayed. IRS Publication 523 closes that gap: if your former spouse is allowed to live in the home under a divorce or separation instrument and uses it as their main home, you are treated as using it too, even though you are not physically there.

If neither of you occupies the home under such an instrument — say it's rented to a third party after the split — you can still count any period you owned the home, solely or jointly with your former spouse, toward the ownership leg. The two legs are tested separately, so a long-owned, recently-vacated home can still pass both.

Scenario 2 · Death of a spouse

Your spouse died and you're selling the home alone

Losing a spouse does not automatically cut the exclusion to the single $250,000 amount. Publication 523 preserves the full $500,000 joint-return exclusion for a surviving spouse who sells within 2 years of the date of death, provided all of the following hold: the survivor hasn't remarried by the sale date, neither spouse excluded gain on another home sale in the 2 years before this sale, and the 2-of-5-year ownership and use tests are otherwise met (generally by either spouse, individually or combined).

Miss that 2-year window and the exclusion drops to $250,000 the day after — a hard deadline worth flagging to an estate attorney early, not discovered at closing.

Scenario 3 · Inherited home

You inherited the house — a different mechanism entirely

This is not a Section 121 question at all — it's a basis question, and it usually makes the tax bill much smaller than heirs expect. Under IRC §1014, property acquired from a decedent generally takes a basis equal to its fair market value on the date of death — not what the decedent originally paid, however low that was (IRS Publication 551). This is the "stepped-up basis."

Sell soon after inheriting, close to the appraised date-of-death value, and the taxable gain is often near zero — a parent's home bought in 1985 for $60,000 and worth $410,000 at death has a basis of roughly $410,000 for the heir, not $60,000. This applies whether or not any heir ever lived there, so the ownership-and-use tests above are usually irrelevant here. One exception worth knowing: appreciated property the decedent received as a gift within one year of death does not get the step-up.

Scenario 4 · Second home or vacation property

It was never your main home

Section 121 excludes gain on a principal residence only. A vacation home, a second home you never lived in as your main residence, or a straight rental property gets no exclusion at all — the full gain is taxed at the long-term capital gains rate your income lands in (0/15/20%), plus depreciation recapture if it was ever rented, plus the 3.8% net investment income tax if you're above the threshold. The one deferral route for this category is a Section 1031 like-kind exchange into another investment property — available only to investment or business property, never to a primary residence.

Scenario 5 · Former rental you moved back into

It was a rental before it was your home again

Two separate rules stack here, and both cut against the seller. First, any depreciation claimed after May 6, 1997 is never excludable under Section 121 — it's taxed separately as unrecaptured Section 1250 gain, at a maximum 25% rate, before the exclusion is even applied.

Second, and less well known: under 26 U.S.C. §121(b)(5), added in 2008, any period after December 31, 2008 that the home was used as a rental or business property rather than your main residence counts as "nonqualified use." The gain is allocated between qualified and nonqualified periods by the ratio of nonqualified time to total ownership time, and the nonqualified share cannot be excluded — even if you separately pass the 2-of-5-year ownership and use tests on the whole property. Reconstructing that allocation needs a full month-by-month use history, which is exactly why our calculator names it as a figure it will not silently estimate. If you cannot reconstruct the depreciation figure the recapture line needs, the rental depreciation calculator rebuilds it from your rental history.

Scenario 6 · Military or Foreign Service orders

You were deployed or posted away for years

The standard test looks back only 5 years, which can knock out an otherwise-qualifying owner who spent years overseas on orders. Under 26 U.S.C. §121(d)(9), a member of the uniformed services, the Foreign Service, the intelligence community, or the Peace Corps on qualified official extended duty — active-duty orders for an indefinite period or more than 90 days, at a post 50+ miles from the home or in government quarters — can elect to suspend the 5-year look-back for up to 10 years, for a maximum look-back of 15 years to find the required 24 months of ownership and use (IRS Publication 523). The election is made per sale, not automatically applied.

Scenario 7 · State tax

Your state adds a separate bill — or doesn't

Every figure above and on the calculator is federal only. What your state does with the same gain varies enormously:

No state income tax at all

Alaska, Florida, Nevada, New Hampshire, South Dakota, Tennessee, Texas, Washington, and Wyoming — a home sale gain isn't taxed at the state level in any of them.

Washington's exception, explained

Washington does run a standalone 7%/9.9% capital gains excise tax on other long-term assets above an annually-adjusted threshold, but real estate is explicitly listed as an exempt asset category — a home sale isn't reached by it (Washington Department of Revenue).

Missouri, since 2025

Missouri became the first state to fully exempt individual capital gains — home sale gains included — from its income tax, for tax years beginning on or after January 1, 2025 (Missouri Department of Revenue).

Everywhere else

Most remaining states tax the gain as ordinary income at their regular state rates, stacked on top of the federal bill this guide's companion calculator works out — check your own state's department of revenue, since rates and any state-level exclusions vary widely and are not modelled here.

Once you've identified your scenario

Run the actual federal number

Gain, exclusion, recapture, and the rate band your gain lands in — built from the same IRS provisions cited above, no signup.

Open the Capital Gains Tax Calculator →

Also useful: the closing costs calculator for the settlement costs that add to your basis, and the cost-to-sell calculator for the full net sheet — commission, payoff, and what actually reaches your account.

Frequently asked questions

Do I owe capital gains tax if my ex-spouse lived in the house after we divorced?+

You can still count that time as your own use. IRS Publication 523 treats a home as your residence for the Section 121 use test if your spouse or former spouse is allowed to live there under a divorce or separation instrument and uses it as their main home — even though you moved out. If neither of you occupies it under such an instrument, you can still count any period you owned the home, solely or jointly, toward the ownership test.

What happens to the capital gains exclusion when a spouse dies?+

A surviving spouse can claim the full $500,000 joint-return exclusion, not the $250,000 single amount, if the home is sold within 2 years of the spouse's death, the survivor hasn't remarried, and neither spouse excluded gain on another home sale in the 2 years before this one (IRS Publication 523, and IRC §121(b)(4)). Miss the 2-year window and the exclusion drops to $250,000.

Do I pay capital gains tax on an inherited house?+

Usually little or none, and for a different reason than Section 121. Under IRC §1014, inherited property generally takes a basis equal to its fair market value on the date of death — not what the decedent originally paid (IRS Publication 551). If you sell soon after inheriting, at close to that appraised value, there is often almost no taxable gain at all, independent of whether you ever lived in the home.

Is there a capital gains exclusion on a second home or vacation home?+

No. Section 121 only excludes gain on a principal residence. A second home, vacation home, or straight rental property that was never your main home gets no exclusion at all — the entire gain is taxable at long-term capital gains rates (0/15/20%) plus any depreciation recapture and the 3.8% net investment income tax, unless it qualifies for a Section 1031 like-kind exchange as investment property.

If I rented my home out before selling it, does the exclusion still apply?+

Partially, and it's more restrictive than most sellers expect. Two separate rules apply: depreciation claimed after May 6, 1997 is never excludable and is taxed separately at up to 25% (unrecaptured Section 1250 gain). Separately, under IRC §121(b)(5), any period after December 31, 2008 that the home was used as a rental or business property rather than your main home is 'nonqualified use,' and the gain is allocated between qualified and nonqualified periods — the nonqualified share loses the exclusion even if you otherwise pass the ownership-and-use tests.

Does military service extend the 5-year ownership-and-use window?+

Yes. Under IRC §121(d)(9), a service member (or eligible Foreign Service, intelligence community, or Peace Corps employee) on qualified official extended duty can suspend the standard 5-year look-back for up to 10 years, giving up to 15 years total to meet the 2-of-5-year ownership and use tests (IRS Publication 523).

Which states have no capital gains tax on a home sale?+

Alaska, Florida, Nevada, New Hampshire, South Dakota, Tennessee, Texas, Washington, and Wyoming levy no state income tax, so a home sale gain isn't taxed at the state level in any of them. Washington is a partial exception in name only — it does have a standalone 7%/9.9% capital gains excise tax on other assets, but real estate is explicitly exempt from it (Washington Department of Revenue). Missouri became the first state to exempt individual capital gains from its income tax entirely for tax years beginning in 2025 (Missouri Department of Revenue). Most other states tax the gain as ordinary income at their regular rates, on top of the federal bill.

Methodology

Every rule above is federal and cited to its own IRS publication, IRS topic page, or U.S. Code section, read September 3, 2026. This guide does not repeat the base Section 121 mechanics, the rate-band derivation, or the worked examples already on the capital gains tax calculator, which carries those in full — it covers the seven situations that page's own "not modelled" disclosure names as too fact-specific for a five-input calculator to compute honestly: divorce, a surviving spouse, an inherited home, nonqualified use, and military-duty suspension. The state-tax section reflects each cited state's department of revenue as of September 2026 and is not a complete 50-state survey — verify your own state's current treatment before relying on it. This guide is educational, not tax advice; consult a CPA or IRS Publication 523 for your specific situation.

Sources

  1. IRS Publication 523 — Selling Your Home (divorce, surviving spouse, military duty suspension) — accessed 2026-09-03
  2. IRS Topic no. 701 — Sale of Your Home (Section 121 exclusion amounts and tests) — accessed 2026-09-03
  3. IRS Publication 551 — Basis of Assets (stepped-up basis for inherited property, IRC §1014) — accessed 2026-09-03
  4. IRS Topic no. 409 — Capital Gains and Losses (rate bands, unrecaptured §1250 gain) — accessed 2026-09-03
  5. 26 U.S.C. §121(b)(5) — Nonqualified use allocation, added by the Housing and Economic Recovery Act of 2008 — accessed 2026-09-03
  6. 26 U.S.C. §121(d)(9) — Suspension of 5-year period for qualified official extended duty — accessed 2026-09-03
  7. Washington Department of Revenue — Capital Gains Tax (real estate exemption) — accessed 2026-09-03
  8. Missouri Department of Revenue — Missouri, First State to Fully Exempt Capital Gains Tax — accessed 2026-09-03