GeniusRealty

Home Sale Capital Gains & the 2-of-5 Rule (IRS §121)

Last reviewed 2026-09-25

Most home sellers owe no federal capital-gains tax on a main home, because IRS §121 excludes up to $250,000 of gain for single filers and $500,000 for married couples filing jointly. The catch is the 2-of-5 rule: you must have owned the home and lived in it as your primary residence for at least 2 of the last 5 years. Only the gain above the exclusion is taxed, and a few traps — especially depreciation recapture — still bite.

How the gain is calculated

Taxable gain = amount realized − adjusted basis. Your basis starts as the purchase price, plus capital improvements, minus any depreciation claimed. Only the gain above the exclusion amount is taxed. (Source: IRS Pub 523.)

The three tests

TestRuleSource
OwnershipYou owned the home for at least 2 of the last 5 years (24 months, need not be consecutive).IRS Pub 523
UseYou lived in it as your primary residence for at least 2 of the last 5 years (24 months, need not be consecutive).IRS Pub 523
LookbackYou haven't claimed the §121 exclusion on another home in the prior 2 years.IRS Pub 523

Partial exclusion and special cases

If you sell early because of a job move, health issue, or unforeseen circumstance, a partial exclusion can still apply, prorated by how much of the 2-year period you met. Uniformed-service, foreign-service, and intelligence-community members can have the 5-year lookback suspended for up to 10 years during qualified official duty — which is often what preserves the exclusion on a long-term rental conversion. (Source: IRS Pub 523.)

The traps

Where the timing decision lives

The 2-of-5 lookback is why sell-now-vs-hold timing matters: moving out and renting converts future gain above the exclusion into taxable gain once the window closes. Our sell vs stay guide walks through the full decision — the home sale proceeds calculator and home sale proceeds guide cover the transaction costs that come out of the sale before any tax question even arises.

FAQ

How much capital gain on a home sale is tax-free?

Under IRS §121 you can exclude up to $250,000 of gain if single or married filing separately, or up to $500,000 if married filing jointly — if you pass the ownership and use tests.

What is the 2-of-5 rule?

You must have owned the home at least 2 of the last 5 years and lived in it as your primary residence at least 2 of the last 5 years. The 24 months don't need to be consecutive, and the 5-year lookback is what makes a shorter absence workable.

Do both spouses need to meet the tests for the $500,000 exclusion?

For joint filers, at least one spouse must meet the ownership test, both must meet the use test, and neither spouse can have claimed the exclusion on another home in the prior 2 years (IRS Pub 523).

What happens if I moved out and rented the house before selling?

You can still qualify as long as you lived in it 2 of the last 5 years — renting for up to ~3 years can preserve the exclusion. But depreciation claimed while renting cannot be excluded and is taxed as unrecaptured Section 1250 gain (up to 25%). Certain service members and foreign-service/intelligence employees get the 5-year lookback suspended for up to 10 years.

Sources

All figures cited from IRS Topic 701 and IRS Publication 523, retrieved 2026-09-25. This page is general information, not tax advice — confirm your situation with a tax professional.