To exclude gain from the sale of your home under Internal Revenue Code Section 121, you have to pass two separate tests: you must have owned the property for at least two years, and you must have lived in it as your principal residence for at least two years, both measured within the five-year period ending on the sale date. Pass both, and a single filer can exclude up to $250,000 of gain from income; married couples filing jointly can exclude up to $500,000 if they meet added conditions.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence The two tests run on independent clocks, so the ownership months and the use months don’t have to be the same months.
The exclusion covers a range of dwelling types: a single-family house, condominium, cooperative apartment, mobile home, or houseboat can all qualify as a main home.2Internal Revenue Service. Publication 523 (2025), Selling Your Home What matters is whether you owned it and actually lived in it for long enough.
The Ownership Test
You must have owned the property for at least two years during the five-year period ending on the sale date. The IRS counts two years as 24 full months or 730 days.3eCFR. 26 CFR 1.121-1 – Exclusion of Gain From Sale or Exchange of a Principal Residence The five-year window rolls forward with time, so what matters is the period immediately before closing, not when you first bought the home.
Ownership means holding legal title. A lease-to-own arrangement doesn’t count until title actually transfers to you. If you hold the property through an LLC or corporation, the entity owns the property, not you, and Section 121 applies to individuals.
The Use Test
Separately from ownership, you must have lived in the home as your principal residence for at least two years (730 days) during the same five-year lookback window. The days don’t need to be consecutive.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence Vacations and other short absences still count as time you lived at home, even if you rented the place out while you were gone.2Internal Revenue Service. Publication 523 (2025), Selling Your Home
If you own more than one property, the IRS looks at where you actually spent most of your time. Indicators of a principal residence include the address on your voter registration, driver’s license, and federal tax returns, along with where you work and where your utility accounts are active. A vacation home or seasonal getaway you visit a few weeks a year won’t qualify, no matter how long you’ve owned it.
Keep a basic log of where you were. During an audit, the burden falls on you to demonstrate that you lived in the home long enough. Flight records, utility usage patterns, and even gym check-ins can help build the case.
How the Two Tests Fit Together
The ownership and use requirements are separate. You don’t need the two-year ownership period and the two-year use period to be the same two years. A renter who buys the home they’ve been living in, then sells two years later, can pass both. So can an owner who rented the home out for part of the five-year window, as long as at least two years of ownership and two years of personal use each fall inside that window.
A third condition sits alongside the two tests: you can only use the Section 121 exclusion once every two years. If you excluded gain on the sale of any other home during the two-year period ending on the date of your current sale, you’re disqualified from the full exclusion.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence The only escape is a partial exclusion for a qualifying job move, health issue, or unforeseen circumstance.
Special Counting Rules That Change Who Passes
Military and Foreign Service Suspension
Members of the uniformed services, Foreign Service, intelligence community, and Peace Corps volunteers can suspend the five-year lookback for up to 10 years while on qualified official extended duty. That stretches the window to as long as 15 years, giving you far more time to meet the two-year use requirement.2Internal Revenue Service. Publication 523 (2025), Selling Your Home
To qualify, you must be serving at a duty station at least 50 miles from your main home, or living in government quarters under orders, with active duty for an indefinite period or for more than 90 days. You can only suspend the five-year period for one property at a time. You make the election by filing your return for the sale year and excluding the gain.
Divorce and Separation
Divorce affects both tests. If you received ownership of the home from your spouse or former spouse in a transfer related to the divorce, your ownership period includes the time your ex-spouse owned it.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence The ownership clock does not restart when the deed transfers to you.
For the use test, if your ex-spouse continues living in the home under a divorce or separation instrument, that time counts as your use of the home even after you move out. The instrument must be a divorce decree, a written separation agreement, or a support order. Simply moving out without any written agreement doesn’t preserve your use period.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence This is the most common mistake in divorce-related home sales: the spouse who moves out assumes they’ll still qualify, but without the written instrument in place, their use clock stops.
Surviving Spouse
A surviving spouse can claim the full $500,000 exclusion if the home is sold within two years of the spouse’s death, provided you haven’t remarried at the time of the sale, neither you nor your late spouse used the exclusion on another home in the prior two years, and the ownership and use requirements are otherwise met. For those requirements, any time your late spouse owned and lived in the home counts as yours.2Internal Revenue Service. Publication 523 (2025), Selling Your Home
Sell more than two years after your spouse’s death and you drop to the $250,000 individual exclusion. Timing matters here.
Married Couples: Extra Conditions on Top of the Tests
The $500,000 joint exclusion requires three things beyond the basic tests. At least one spouse must satisfy the two-year ownership test. Both spouses must independently meet the two-year use test. And neither spouse can have used the Section 121 exclusion on another home sale within the prior two years.4eCFR. 26 CFR 1.121-2 – Limitations That third requirement catches people off guard in second marriages where one spouse recently sold a prior home.
If the couple doesn’t meet all three conditions, the exclusion isn’t necessarily zero. Each spouse calculates their own individual exclusion as if unmarried, and the couple’s combined limit equals the sum.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence If one spouse qualifies for the full $250,000 and the other qualifies for nothing, the couple can still exclude $250,000.
Partial Exclusion When You Can’t Pass the Full Tests
Selling before you’ve hit two years of ownership or use doesn’t automatically wipe out the exclusion. If the sale is primarily driven by a change in place of employment, a health issue, or an unforeseen circumstance, you may qualify for a prorated exclusion.2Internal Revenue Service. Publication 523 (2025), Selling Your Home
A job-related sale qualifies if your new workplace is at least 50 miles farther from the home than your old workplace was. If your old office was 15 miles from the home, the new one must be at least 65 miles away.2Internal Revenue Service. Publication 523 (2025), Selling Your Home
A health-related sale must be motivated by the need to obtain, provide, or facilitate diagnosis, treatment, or care for a specific disease, illness, or injury affecting you, your spouse, or a family member. A physician’s recommendation carries significant weight and serves as a safe harbor, though it isn’t strictly required. Selling to improve general well-being doesn’t qualify.
The IRS also recognizes safe harbor events that automatically count as unforeseen circumstances:
- Death of a taxpayer, spouse, co-owner, or household member
- Job loss resulting in eligibility for unemployment compensation
- An employment change that leaves you unable to pay basic housing and living costs
- Divorce or legal separation
- Multiple births from the same pregnancy
- Natural disaster, terrorism, or act of war damaging the residence
- Involuntary conversion of the property, such as condemnation
If your situation doesn’t fit a safe harbor, you can still argue unforeseen circumstances based on the facts, but you’ll need strong documentation.5Department of the Treasury. Reduced Maximum Exclusion of Gain From Sale or Exchange of Principal Residence (TD 9031)
The math is simple. Take the number of months you met the requirements (using whichever test you satisfied the least), divide by 24, and multiply by $250,000 or $500,000. A single taxpayer who lived in the home for 12 months before a qualifying job relocation would compute 12 ÷ 24 × $250,000 = $125,000.2Internal Revenue Service. Publication 523 (2025), Selling Your Home
Non-Qualified Use Can Shrink the Exclusion Even If You Pass
Passing the two tests doesn’t always mean the full exclusion applies to your entire gain. If you used the property for something other than your principal residence at any point after 2008, part of your gain may not be excludable. The IRS calls this a “period of nonqualified use,” and the portion of gain you can’t exclude equals the ratio of nonqualified-use days to total ownership days.2Internal Revenue Service. Publication 523 (2025), Selling Your Home Rental periods and stretches when neither you nor your spouse lived there are the common triggers.
Some periods are excluded from the nonqualified-use calculation. Any period after the last date you used the home as your principal residence doesn’t count against you. Military service suspension periods are excluded, as are temporary absences of up to two years total for job changes, health, or unforeseen circumstances.2Internal Revenue Service. Publication 523 (2025), Selling Your Home Periods before January 1, 2009, are always disregarded, even if the home was a rental then.6Cornell Law School (Legal Information Institute). 26 USC 121 – Exclusion of Gain From Sale of Principal Residence
Depreciation is a separate matter. If you claimed depreciation deductions on the home after May 6, 1997, for a home office or rental use, the portion of your gain equal to that depreciation can never be excluded under Section 121. That amount is taxed as unrecaptured Section 1250 gain at a maximum rate of 25%.7Internal Revenue Service. Sales, Trades, Exchanges 3