Capital Gains Exemption: Primary Residence Rules, Limits, and Tests

The capital gains exemption on a primary residence lets you shield up to $250,000 of profit from federal tax when you sell your home, or up to $500,000 if you’re married and file jointly. The rule sits in Section 121 of the Internal Revenue Code, and most home sellers end up owing nothing because of it.1Office of the Law Revision Counsel. 26 US Code 121 – Exclusion of Gain From Sale of Principal Residence Qualifying depends on how long you owned the home, how long you lived in it, and whether you’ve used the exclusion recently. Calculating the actual gain takes more work than subtracting the purchase price from the sale price.

The Ownership and Use Tests

Two tests decide whether you qualify. You must have owned the home for at least two years during the five-year period ending on the sale date, and you must have used it as your main home for at least two years during that same window.1Office of the Law Revision Counsel. 26 US Code 121 – Exclusion of Gain From Sale of Principal Residence

The two years don’t have to be continuous. You could live in the home for 14 months, move out and rent it for two years, then move back for 10 months and still meet the use test. The math only cares that the days add up to 24 months inside the five-year lookback.

There’s also a frequency limit. The exclusion is available once every two years. If you claimed it on another home sale within the past 24 months, you generally cannot claim it again now.1Office of the Law Revision Counsel. 26 US Code 121 – Exclusion of Gain From Sale of Principal Residence A separate partial exclusion exists for people forced to sell early, covered further down.

Which Home Counts as Your Primary Residence

If you own more than one property, the IRS looks at where you actually live, not what you label the home. The place you spend most of the year usually wins, but the agency also weighs where you work, where your family lives, the address on your tax returns and driver’s license, where you’re registered to vote, and where you bank. No single factor decides it, but the facts have to line up.

A couple with a suburban house and a beach condo can only claim the exclusion on the property that genuinely functions as their main home. Calling something your primary residence on paper doesn’t make it so.

How Much You Can Exclude

  • Single filers can exclude up to $250,000 of gain.
  • Married couples filing jointly can exclude up to $500,000, but only if at least one spouse meets the ownership test, both spouses meet the use test, and neither has claimed the exclusion on another sale in the past two years.1Office of the Law Revision Counsel. 26 US Code 121 – Exclusion of Gain From Sale of Principal Residence
  • Married filing separately, each spouse can exclude up to $250,000 on their own return if they independently pass both tests.

The joint $500,000 threshold trips couples up more often than expected. If only one spouse lived in the home for two of the past five years, the couple is limited to $250,000 on a joint return, not the full $500,000. This comes up when one spouse owned the home before the marriage or when the two kept separate residences.1Office of the Law Revision Counsel. 26 US Code 121 – Exclusion of Gain From Sale of Principal Residence

Calculating Your Gain

Your gain isn’t simply the sale price minus the purchase price. The IRS works from adjusted basis, which starts with what you paid and adjusts upward for certain costs.

Basis begins with the purchase price plus closing costs you paid when buying: title insurance, legal fees, recording fees, and transfer taxes. On top of that, add capital improvements you made over the years. An improvement adds value, extends the home’s useful life, or adapts it to a new purpose. A kitchen remodel, a new roof, a finished basement, and a new HVAC system all qualify. Routine maintenance like repainting or fixing a leaky pipe does not.2Internal Revenue Service. Publication 523, Selling Your Home

On the sale side, subtract your selling expenses from the sale price to get the amount realized. Selling expenses include agent commissions, advertising, legal fees, and any loan charges you paid on the buyer’s behalf.2Internal Revenue Service. Publication 523, Selling Your Home Your gain is the amount realized minus the adjusted basis. The exclusion comes off after that.

A concrete example. You bought for $300,000 and spent $50,000 on improvements, giving an adjusted basis of $350,000. You sell for $650,000 and pay $40,000 in commissions, so the amount realized is $610,000. Your gain is $260,000. A single filer would exclude $250,000 and owe tax on the remaining $10,000. A married couple filing jointly would exclude the full $260,000 and owe nothing.

Keep receipts, contractor invoices, and settlement statements. If the IRS audits the sale, you’ll need documentation showing what you paid, when the work was done, and that it counts as an improvement rather than a repair.2Internal Revenue Service. Publication 523, Selling Your Home

Tax on Gain Above the Exclusion

Profit above the excluded amount is taxed as a long-term capital gain, assuming you owned the home for more than one year. For 2026 the federal rates are:

  • 0% if total taxable income falls below $49,450 (single), $98,900 (married filing jointly), or $66,200 (head of household).
  • 15% for income between those thresholds and $545,500 (single), $613,700 (married filing jointly), or $579,600 (head of household).
  • 20% for income above those upper thresholds.3Tax Foundation. 2026 Tax Brackets and Federal Income Tax Rates

The 0% bracket is easy to overlook. A single retiree with modest other income could sell, have a gain slightly above the $250,000 exclusion, and still owe zero federal tax on the excess.

High-income sellers face an additional 3.8% net investment income tax on top of the capital gains rate when modified adjusted gross income exceeds $200,000 (single), $250,000 (married filing jointly), or $125,000 (married filing separately).4Internal Revenue Service. Net Investment Income Tax Combined with the 20% bracket, the top federal rate reaches 23.8%. Most states also tax capital gains as ordinary income, and nine states have no income tax at all.

Partial Exclusion When You Have to Sell Early

Falling short of the two-year ownership or use requirement doesn’t always mean you lose the exclusion. If the sale happened because of a job change, a health reason, or an unforeseen circumstance, a partial exclusion may shelter some of the gain.

The job-change safe harbor is the cleanest. If your new workplace is at least 50 miles farther from the home than your old one was, you qualify automatically. Health-related sales qualify when a doctor recommends the move or when selling is necessary to obtain medical care. Unforeseen circumstances include divorce, natural disasters, job loss, and the death of a household member.

To calculate the partial amount, take the shortest of three periods: how long you lived in the home, how long you owned it, or the time since you last used the exclusion. Divide that period by 24 months (or 730 days), then multiply by $250,000 for a single filer, computing each spouse’s share separately for a joint return.2Internal Revenue Service. Publication 523, Selling Your Home

A single homeowner who lived in the home for 15 months before a qualifying job move would calculate 15 ÷ 24 = 0.625, then 0.625 × $250,000 = $156,250. That’s the maximum gain excludable. Not the full amount, but often enough to erase the tax bill on a sale that would otherwise be fully taxable.

Prior Rental Use and Depreciation

If you ever rented the home or claimed a home office deduction, part of the gain sits outside the Section 121 exclusion. Any depreciation you claimed (or could have claimed) after May 6, 1997, must be recaptured as taxable income at a maximum rate of 25%.5Internal Revenue Service. Topic No. 409, Capital Gains and Losses The recapture applies even when the rest of the gain is fully excluded.

Say you rented the home for three years and claimed $30,000 in depreciation. That $30,000 is taxable at up to 25% whether or not your remaining gain fits within the $250,000 or $500,000 limit. The recaptured amount is the lesser of total depreciation taken or the gain on the sale.

Nonqualified Use Periods

Time the property was used for something other than your primary residence can also chip away at the exclusion. Divide the total time of nonqualified use by the total time you owned the property, and that fraction of the gain cannot be excluded.6Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence

Order matters. Rental use before you move in counts as nonqualified use and shrinks your exclusion. Rental use after you move out does not count as nonqualified use, as long as the property was your primary residence at some point during the five-year window.6Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence Live in a home for four years and then rent it out for two before selling, and the rental period doesn’t reduce your exclusion. Flip the sequence and you lose a piece of it.

When both rules apply, depreciation recapture runs first, then the nonqualified use ratio applies to the remaining gain. That order prevents the same dollars from being taxed twice, but it also means the math has to be worked through in sequence.

Surviving Spouses

When one spouse dies, the surviving spouse can still claim the full $500,000 joint exclusion, but only on a sale within two years of the date of death. The ownership and use requirements had to be met immediately before the spouse passed away, and the surviving spouse has to be unmarried at the time of sale.6Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence

That two-year window catches people off guard. A widow who stays in the home for three years after her husband’s death and then sells qualifies only for the $250,000 single exclusion, even if the couple would easily have qualified for $500,000.

A separate rule often works alongside this one. When a spouse dies, the survivor receives a stepped-up basis in the decedent’s share of the property, resetting it to the fair market value on the date of death.7Office of the Law Revision Counsel. 26 US Code 1014 – Basis of Property Acquired From a Decedent In community property states, both halves get stepped up. The basis increase can eliminate most of the gain before the exclusion is even applied.

Military and Foreign Service Suspension

Members of the uniformed services, the Foreign Service, and certain intelligence community employees can suspend the five-year lookback for up to 10 years while serving on qualified official extended duty at a station at least 50 miles from the home.1Office of the Law Revision Counsel. 26 US Code 121 – Exclusion of Gain From Sale of Principal Residence

In practice, a qualifying servicemember could live in a home for two years, receive orders to a distant duty station for up to 10 years, and still claim the full exclusion on sale. The two-of-five-year use test effectively becomes a two-of-fifteen-year test. The election covers one property at a time and extends to spouses. Many military families never learn it exists.

Inherited Homes

If you inherit a home instead of buying one, your basis is generally the fair market value on the date of the prior owner’s death, not what they originally paid.7Office of the Law Revision Counsel. 26 US Code 1014 – Basis of Property Acquired From a Decedent A parent who bought for $80,000 in 1985 might pass the home on when it’s worth $400,000. Your basis is $400,000.

Move into the inherited home and use it as your primary residence for at least two of the next five years, and you can also claim the Section 121 exclusion on any appreciation after you inherit. The stepped-up basis plus the exclusion means inherited homes rarely produce a large taxable gain, though the ownership and use tests still have to be met.

Reporting the Sale

Not every home sale needs to appear on your tax return. If the gain is fully covered by the exclusion and you didn’t receive a Form 1099-S from the closing agent, you don’t have to report the sale at all.2Internal Revenue Service. Publication 523, Selling Your Home

You do have to report the sale if:

  • Your gain exceeds the exclusion amount and there’s taxable profit.
  • You received a Form 1099-S, even if the gain is fully excludable.
  • You choose to treat the gain as taxable because you plan to sell a more expensive home within two years and want to save the exclusion for the bigger gain.2Internal Revenue Service. Publication 523, Selling Your Home

When reporting is required, the sale is recorded on Form 8949 and the totals flow to Schedule D of Form 1040.8Internal Revenue Service. Instructions for Form 8949

Skipping a gain that should have been reported can bring an accuracy-related penalty of 20% of the tax underpayment, plus interest from the return’s original due date.9Internal Revenue Service. Accuracy-Related Penalty The penalty can apply even when the oversight was unintentional, though the IRS may waive it for reasonable cause.