Skip to main content

Section 121 and renting out your former home: the 2-of-5-year rule

You can still exclude up to $250,000 of gain ($500,000 for most joint filers) on a home you rented out, if you owned it and lived in it as your main home for at least 2 of the 5 years before the sale. Renting it after you move out does not count against you. But depreciation you took after May 6, 1997 is taxed, and any period after 2008 when it was rented before you lived in it can shrink the exclusion.

The 2-of-5-year rule

Section 121 of the tax code says gain on the sale of property is excluded if, during the 5-year period ending on the date of sale, you owned and used the property as your principal residence for periods adding up to 2 years or more. The exclusion is capped at $250,000, or $500,000 for a married couple filing jointly who meet the rules (26 U.S.C. 121).

Publication 523 explains the two tests. For ownership, you must have owned the home for at least 24 months out of the last 5 years. For residence, you must have used it as your home for at least 24 months (730 days) of the previous 5 years, and the 24 months can fall anywhere in the period and do not have to be one block. A vacation or short absence counts as time at home even if you rented the home out while you were gone.

You moved out and rented it. Is the exclusion gone?

Not if you sell in time. Because the test looks back 5 years from the sale, you generally have up to about 3 years after moving out to sell and still have 2 years of residence inside the window. Renting during those years does not cancel the exclusion.

The rental years after you last lived there are also kept out of the nonqualified use rule. Publication 523 says a period of nonqualified use does not include any part of the 5-year period ending on the date of the sale that comes after the last date you used the property as your main home.

Depreciation is taxed even when the gain is excluded

Publication 523 says you cannot exclude the part of the gain equal to depreciation allowed or allowable for periods after May 6, 1997. That depreciation is reported on Form 4797 and is not covered by the exclusion. Allowable matters: if you could have taken depreciation and did not, the rule still treats it as taken. See what to do when you forgot to depreciate.

Example a made-up owner bought a home on January 1, 2020 for $300,000, lived in it through December 31, 2023, then rented it from January 1, 2024. The owner sells on December 31, 2026 for $520,000 and has claimed $24,000 of depreciation. The residence test is met (2022 and 2023 give 24 months inside the 5-year window), and the rental years are after the last use as a main home, so there is no nonqualified use. The total gain is $520,000 minus ($300,000 minus $24,000), which is $244,000. Take out the $24,000 of depreciation that cannot be excluded and $220,000 remains, which is under $250,000, so all of it is excluded. The $24,000 is taxed. Selling costs and improvements would change the figures; your preparer works the final numbers.

Nonqualified use: when it was a rental first

After 2008 the law added a rule for the reverse order. Publication 523 says gain is not excludable to the extent it is allocated to periods of nonqualified use, meaning any period after 2008 when neither you nor your spouse used the property as your main home. There are exceptions, including the time after the last date you used it as your main home, certain qualified official extended duty up to 10 years, and some temporary absences up to 2 years in total for a change of employment, health or other unforeseen circumstances.

Example a made-up owner buys a home on January 1, 2021 for $400,000 and rents it out for 2021 and 2022, claiming $20,000 of depreciation. The owner moves in on January 1, 2023, lives there through December 31, 2025, and sells that day for $660,000. The gain is $660,000 minus ($400,000 minus $20,000), which is $280,000. Remove the $20,000 of depreciation and $260,000 is left. The rental was 2 of the 5 years, so 40% of $260,000, which is $104,000, is allocated to nonqualified use and is not excludable. The other $156,000 is under the $250,000 cap and is excluded. The owner reports the $104,000 as long-term capital gain and the $20,000 as depreciation recapture.

Publication 523 includes a Worksheet 3 that does this allocation, and its own worked example of this kind has the same shape. The takeaway: renting first and moving in later is worse than living there first and renting afterward.

What if you do not want to sell yet?

The clock keeps running while you rent, and it is easy to miss the date it runs out. Mark on a calendar the day three years after you moved out, and decide before it passes whether to sell. An owner who plans to keep the rental has other tools, such as a 1031 exchange, though Publication 523 notes you cannot convert the replacement property to a main home immediately after the exchange. Because the interaction of the two rules is technical, take that one to your tax preparer before you act.

How DoorKeeping handles it

DoorKeeping keeps each property's books, including depreciation on Schedule E line 18 from the day it became a rental, so the total depreciation you will report on a sale is in one place. Move-in and rental start dates can be saved with the property's documents. DoorKeeping does not calculate the exclusion or give tax advice, so check the numbers with your tax preparer before you sell. It costs $2 per unit per month with no other fees.

Sources

  1. IRS, Publication 523, Selling Your Home (2025): eligibility tests; Business or Rental Use of Home; nonqualified use, read Oct 30, 2026
  2. Cornell LII, 26 U.S.C. 121, Exclusion of gain from sale of principal residence, read Oct 30, 2026
  3. IRS, Publication 527, Residential Rental Property (2025), read Oct 30, 2026

Questions

How long can I rent my home and still use the exclusion?
The 2 years of residence must fall within the 5 years before the sale, so you generally have about 3 years after moving out to sell. The rental years after your last use as a main home are not nonqualified use.
Do I owe tax on the depreciation I took?
Yes. Publication 523 says gain equal to depreciation allowed or allowable after May 6, 1997 cannot be excluded and is reported on Form 4797.
Does it matter if I rented it before I lived in it?
It can. After 2008, periods when it was not your main home before you moved in are nonqualified use, and the share of gain allocated to them cannot be excluded.