Why NomadPricing

Nomad Blog

Back to all posts

2-Out-of-5-Year Rule: Selling a Home You've Rented Out

Last updated on: Nov 18, 2026

Published on: Jan 30, 2024

Hero Image

If you've moved out of your home and started renting it, the question of when to sell carries a tax deadline you may not know about. The IRS lets most homeowners keep up to $250,000 of profit tax-free when they sell their main home ($500,000 for married couples filing jointly), but only if they lived there for two of the five years before the sale. For a landlord who has moved out, that usually means selling within three years of the move-out date.

This guide covers how the 2-out-of-5-year rule works, how renting the home affects it, what you still owe tax on even when you qualify, and the exceptions that can save a partial exclusion. Nomad isn't a tax advisor, and nothing here is tax advice. Tax rules change and your situation is specific to you, so confirm the details with a CPA or tax professional before you sell.

The short answer

  • What the rule is: The 2-out-of-5-year rule is the test in Section 121 of the tax code that decides whether you can exclude up to $250,000 ($500,000 married filing jointly) of gain when you sell your main home. You must have owned the home and lived in it as your main home for at least 24 months of the 5 years before the sale.

  • The months don't have to be in a row. Any 24 months of ownership and any 24 months of living there within the 5-year window count.

  • If you've moved out and rented it, you generally have three years from the day you moved out to sell and still qualify, as long as you lived there at least two years before moving out.

  • Depreciation is never excluded. Any depreciation you claimed (or could have claimed) while renting the home is taxed when you sell, at a rate of up to 25%.

  • You can use the exclusion once every two years. If you excluded gain on another home sale in the two years before this one, you don't qualify.

What is the 2-out-of-5-year rule?

The 2-out-of-5-year rule is the eligibility test for the home sale exclusion in Section 121 of the Internal Revenue Code. When you sell your main home for more than you paid, the profit is a capital gain. If you pass the test, you can exclude up to $250,000 of that gain from your income, or up to $500,000 if you're married and file jointly. Those limits have been the same since 1997 and aren't adjusted for inflation.

IRS Publication 523 (for 2025 returns) breaks the test into three parts:

  1. Ownership test: You owned the home for at least 24 months in the 5 years before the sale date.

  2. Residence test: You lived in the home as your main home for at least 24 months in the same 5-year window.

  3. Look-back test: You didn't exclude gain from the sale of another home in the 2 years before this sale.

The ownership and residence periods don't have to overlap or run back to back. You could live in the home for 12 months, rent it for 2 years, and live there for another 12 months, and still meet the residence test. A vacation or other short absence counts as time you lived in the home, even if you rented it out while you were away.

Married couples: to claim the full $500,000, you file jointly, at least one spouse meets the ownership test, both spouses meet the residence test, and neither has used the exclusion in the past two years. If only one spouse qualifies, that spouse can generally exclude up to $250,000.

How the rule works when you rent out your home

You can rent out a former residence and still use the exclusion, but only for a limited time. Because the 24 months of living in the home have to fall inside the 5 years before the sale, every month you rent pushes your residence period further back in that window. Once you've been gone more than three years, you no longer have 24 months of residence in the last five. If you're deciding between selling now and renting longer, our guide to your three options for a home you've moved out of compares renting, selling, and a 1031 exchange.

That gives most landlords a simple rule of thumb: if you lived in the home for at least two years before moving out, sell within three years of your move-out date to keep the full exclusion.

The IRS also protects that rental period. Time after you last lived in the home, within the 5-year window, isn't counted as "nonqualified use," so renting the home after you move out doesn't shrink your exclusion. The depreciation you claim while renting is still taxed, as the next section explains.

Timeline showing that a home lived in for two years and then rented must be sold within three years of move-out to keep the full home sale exclusion.

You lived in the home

You moved out

Sell by (to keep the full exclusion)

March 2021 to March 2023 (24 months)

March 2023

March 2026

August 2020 to July 2024 (about 4 years)

July 2024

July 2027

June 2023 to June 2025 (24 months)

June 2025

June 2028

The dates above assume no other exceptions apply. Count carefully: the residence test is measured in full months or 730 days, so selling a few weeks past the three-year mark can mean failing it.

Example: selling a home you rented for three years

Dana buys a home in 2020 for $400,000 and lives in it until June 2023, then moves for a new job and rents the house out. While it's a rental, Dana claims about $33,000 of depreciation. In May 2026, less than three years after moving out, Dana sells for $560,000 and pays $30,000 in selling costs.

  • Adjusted basis: $400,000 minus $33,000 of depreciation = $367,000

  • Amount realized: $560,000 minus $30,000 = $530,000

  • Total gain: $530,000 minus $367,000 = $163,000

  • Depreciation portion (taxable, up to 25%): $33,000

  • Excluded under Section 121: the remaining $130,000

Had Dana waited until late 2026 to sell, the residence test would fail and the full $163,000 would be taxable as a capital gain.

Dana's $163,000 gain: $130,000 excluded under Section 121 and $33,000 of depreciation that remains taxable.

What you still owe: depreciation recapture

When you rent out your home, you can deduct depreciation on the building each year (residential rental property is depreciated over 27.5 years). That deduction lowers your tax bill while you rent, but it also lowers your basis in the home, which raises your gain when you sell.

Section 121 doesn't let you exclude the part of your gain equal to depreciation taken after May 6, 1997. The IRS applies this to depreciation "allowed or allowable," which means the amount you were entitled to claim counts even if you never claimed it. That portion is generally taxed at a maximum federal rate of 25%. Skipping depreciation to avoid this doesn't work, which is why our guide to rental property tax deductions treats depreciation as a deduction to claim every year.

Renting before you move in: nonqualified use

Renting the home after you've lived there is protected, but renting it before you move in is not. Since 2009, any period when the home wasn't your main residence, other than the period after you last lived there, counts as "nonqualified use," and the share of your gain tied to that period can't be excluded.

For example, say you buy a house in January 2021, rent it out for two years, move in January 2023, and sell in January 2026. You owned it for five years and two of them were nonqualified use, so 40% of your gain (after setting aside depreciation, which is taxed separately) isn't eligible for the exclusion. The other 60% is, up to the $250,000 or $500,000 limit.

Comparison showing that renting after living in a home keeps the full exclusion, while renting before moving in reduces it.

Two other periods aren't counted as nonqualified use: up to 10 years of qualified official extended duty for members of the military, Foreign Service, or intelligence community, and up to 2 years of temporary absence due to a job change, health condition, or other unforeseen circumstance.

If you don't meet the 2-year rule: partial exclusions

If you sell before you've lived in the home for 24 months, you may still qualify for a reduced exclusion when the main reason for the sale is one of these:

  • A work-related move: a new job location at least 50 miles farther from the home than your old work location.

  • A health-related move: moving to obtain, provide, or facilitate diagnosis or treatment of a disease, illness, or injury, for you or certain family members.

  • An unforeseeable event, including death, divorce or legal separation, giving birth to two or more children from the same pregnancy, becoming eligible for unemployment compensation, a change in employment that leaves you unable to pay basic living expenses, the home being destroyed or condemned, or a casualty loss from a disaster.

The reduced exclusion is based on how much of the two years you completed. Divide the shortest qualifying period (your time living in the home, your time owning it, or the time since you last used the exclusion) by 24 months, then multiply by $250,000. A single owner who lived in the home for 12 months before a qualifying job move can exclude up to $125,000 (12 ÷ 24 × $250,000).

Other special cases

  • Military, Foreign Service, intelligence community, and Peace Corps: you can choose to suspend the 5-year test period for up to 10 years while on qualified official extended duty. That can let a service member rent the home far longer than three years and still qualify.

  • Surviving spouses: a widowed homeowner can generally still claim up to $500,000 if the home is sold within two years of the spouse's death, the surviving spouse hasn't remarried by the sale date, and the other requirements were met just before the death.

  • Inherited homes: if you inherit a home from someone other than your spouse, you generally need two years of your own ownership and use to qualify. Most heirs who sell soon after don't need the exclusion because of the stepped-up basis, which our guide to renting or selling an inherited house explains.

  • Divorce: a home transferred to a spouse or former spouse as part of a divorce generally isn't treated as a sale. If your former spouse lives in the home under a divorce or separation agreement, that time can count toward your residence test.

  • Homes acquired in a 1031 exchange: if you got the home through a like-kind exchange, you can't claim the exclusion if you sell within 5 years of acquiring it. Our 1031 exchange overview covers how those swaps work.

  • Adjacent vacant land: land next to your home that you used as part of it can be included in the exclusion if both are sold within two years of each other.

How capital gains tax applies to the rest

Any gain you can't exclude is generally taxed as a long-term capital gain if you owned the home for more than a year, at federal rates of 0%, 15%, or 20% depending on your income. Higher earners may also owe the 3.8% net investment income tax on the taxable part of the gain. The depreciation portion is taxed separately at up to 25%. Most states tax capital gains too, so check your state's rules.

Your gain is the amount you sold for, minus selling costs, minus your adjusted basis. Your basis starts with what you paid, goes up with capital improvements (a new roof, an addition), and goes down by depreciation. Keep receipts for improvements, since they reduce the taxable gain.

Should you rent or sell?

For many owners, the three-year window is the deciding factor. If the home has gained a lot of value and you're close to the deadline, selling may save more in taxes than another year of rent will earn. If you're early in the window, have a low mortgage rate, or expect to move back, renting can make sense, and you can still sell later within the window.

A few questions worth answering before you decide:

  • How much gain would be excluded if you sold today, and how much of it is depreciation that's taxable either way?

  • When does your three-year window close, and when does your tenant's lease end? A lease that runs past the deadline can complicate a sale.

  • What will the home earn as a rental after the mortgage, taxes, insurance, maintenance, and vacancy?

  • Would you rather defer gains into another rental through a 1031 exchange than take the exclusion?

Our guide to selling vs. renting your house walks through the tradeoffs.

How Nomad handles this: If you're renting the home in the meantime, Nomad's Guaranteed Rent pays you on a fixed monthly schedule for the term of the lease, whether or not the tenant pays.

See what your home could rent for

Enter your address for a free rent estimate.


Frequently asked questions

New Heights Buffaloes

Reach New Heights

Get a no-obligation estimate for Guaranteed Rent, and see how Nomad can help you earn more with less stress

Nomad Buffalo
Logo

Unlocking economic opportunity for everyone.

Help centerThe Nomad blogAboutCareersPrivacy policy
California Consumer Privacy Act (CCPA) Opt-Out Icon
Your privacy choices

Already a customer with us? Login to your portal

Equal Housing Logo

© 2026 Nomad Labs, Inc. All rights reserved.

Nomad Brokerage LLC

Nomad Brokerage California Inc

California DRE # 02230490

Texas Real Estate Commission Consumer Protection NoticeTexas Real Estate Commission Information about Brokerage Services
Chatbot bubble