Key Takeaways
- The core §121 test: own and use the home as your principal residence for at least 2 of the last 5 years to exclude up to $250,000 of gain ($500,000 for many joint filers) — plus the prior-sale limit.
- The accidental-landlord clock: rent the home out after moving, and you generally have a limited window to sell — with reduced-exclusion and service-related exceptions.
- The one part §121 never shelters: gain from post-May-6-1997 depreciation taken (or allowable) during the rental period is recognized at sale, no matter what.
- Why the order matters — residence-then-rental usually preserves the exclusion, while rental-then-residence allocates part of the gain to non-qualified use.
Start with the rule most homeowners half-know. When you sell your principal residence, Section 121 lets you exclude up to $250,000 of gain from tax — $500,000 for many married couples filing jointly. The price of admission is the 2-of-5 test: you must have owned the home and used it as your principal residence for at least two years out of the five years ending on the sale date. (The ownership and use years both have to fall in that five-year window, but they don't have to be the same two years.) One more gate that's easy to forget: you generally can't have used the §121 exclusion on another home within the two years ending on this sale. And the $500,000 joint-return figure has its own conditions — generally either spouse meets the ownership test, both spouses meet the use test, and neither used the exclusion in the applicable prior period. Meet all of it, and a quarter- or half-million dollars of gain can simply disappear from your return.
Now the situation this page is about: you lived in the home, then moved out and rented it — the "accidental landlord," whether by job move, a slow market, or choice. The good news is that renting doesn't automatically destroy §121. The two-year use requirement looks back over five years, so you can move out, rent the place for a while, and still pass — as long as you sell before those two qualifying years fall outside the five-year window. As an ordinary heuristic, if you lived there two full years, that's roughly a three-year window after moving out to sell and still get the full exclusion. That's not the only path, though: a taxpayer who misses the ordinary test can still qualify for a reduced exclusion when the sale is due to a change in employment, health, or certain unforeseen circumstances, and special qualified-duty rules (military, Foreign Service, and similar) can suspend the five-year clock. Those exceptions have their own guidance; the point here is that "past the window" doesn't automatically mean "nothing."
Here's the first thing that surprises people, and it's not optional: the depreciation piece is never excluded. For the years the home was a rental, you either took depreciation or were entitled to (the code counts it "allowed or allowable"). Section 121 does not exclude the gain attributable to that post-May-6-1997 depreciation — that gain is recognized at sale even when the rest of your gain is fully excluded. Its character follows the ordinary rule: building depreciation generally feeds the unrecaptured §1250 layer, while any shorter-life §1245 property can produce ordinary recapture (the full character mechanics live in Wealth & Exit). So the accidental landlord's best case isn't "tax-free"; it's "exclusion on the appreciation, but still recognize the depreciation."
Now the part almost nobody gets right the first time: the order of events changes the answer. The statute has a concept called non-qualified use — periods (generally after 2009) when the home was not your principal residence — and gain allocated to those periods is not excludable. But there's a crucial exception: any period after the last date you used the home as your principal residence doesn't count as non-qualified use. Read that twice, because it splits the world in two:
- You lived there first, then rented (residence → rental). The rental period comes after your last day of residence, so it generally falls in the exception and isn't non-qualified use. You can still exclude the full gain (minus the depreciation piece) — provided you're inside the 2-of-5 window. This is the ordinary accidental-landlord path, and it's the favorable one.
- You rented first, then moved in (rental → residence). Now the rental period sits before your residence, so it is non-qualified use. Here's the mechanic that's easy to get wrong: it does not simply shrink the $250k/$500k ceiling. Instead, after first setting aside the depreciation-related gain, the remaining gain is allocated to non-qualified use generally by aggregate non-qualified-use time ÷ total ownership period — and that allocated slice can't be excluded. (IRS's own example: two of five ownership years as non-qualified use puts 40% of the remaining gain outside the exclusion.) Convert a rental into your home and living there two years doesn't hand you the whole exclusion — the earlier rental years pull a proportional share of the gain out of it.
Same two years of renting, opposite result — the only difference is which came first. That's the trap worth carrying out of this page.
One more boundary, because it catches investors specifically: if you acquired the home in a §1031 exchange and later convert it to a residence, §121 requires you to own it for at least five years before the exclusion applies. And §121 and §1031 can be combined on a property that's been both a residence and a rental, but the mechanics belong on the exchange and exit pages. Route yourself there before relying on either.
Where does our canonical rental sit in all this? Outside it. That owner bought the property as a pure investment and never lived in it, so §121 provides no exclusion — any sale or exchange then follows the ordinary investment-property gain, basis, and applicable deferral rules (including the sell / 1031 / refinance choice on the exit pages). §121 is specifically a former-residence rule. (Worth noting for any accidental landlord who did accumulate suspended passive losses while renting: §121 is an exclusion, not a nonrecognition provision — the gain is realized and recognized, then qualifying gain is excluded from gross income. So a qualifying sale of the entire interest to an unrelated buyer can still trigger the §469(g) suspended-loss release even though §121 excludes the home-sale gain — but the excluded gain itself isn't passive income that absorbs those losses. The exclusion and the loss release are separate mechanics that can both appear on the same closing; the decision guide and Wealth & Exit carry the §469(g) detail.)
So the plain-English version: the home-sale exclusion can still reach an accidental landlord, but three things govern it — the 2-of-5 clock (sell before your residence years age out, subject to the reduced-exclusion exceptions), the depreciation carve-out (that gain is always recognized), and the order of events (residence-then-rental preserves the exclusion; rental-then-residence allocates a share of the gain to non-qualified use). Know which pattern you're in before you count on a tax-free sale.
✕ "I lived here two years, so the whole sale is tax-free even though I rented it out." Two misses. First, the gain from post-May-6-1997 depreciation during the rental years is recognized no matter what — §121 never excludes it. Second, if you rented before you lived there, that period is generally non-qualified use — a concept that reaches periods generally after 2009 — and a share of your gain (by non-qualified-use time ÷ ownership period) is allocated out of the exclusion; only the residence-then-rental order generally preserves the full exclusion. And either way, the 2-of-5 clock has to still be met on the sale date (or a reduced-exclusion exception has to apply).
Your Action Plan
- Check the 2-of-5 clock first: will you still have two years of principal-residence use within the five years ending on your sale date? If you moved out, you're on a timer — and if you've missed it, check whether a reduced-exclusion reason (job change, health, unforeseen circumstances) or a qualified-duty rule applies before concluding you're out.
- Identify your order of events: residence-then-rental (generally preserves the exclusion) or rental-then-residence (a share of the gain is allocated to non-qualified use). This changes the number more than anything else.
- Expect to recognize the gain from depreciation taken (or allowable) during the rental years — budget for it; §121 won't cover it, and its character follows the §1245/§1250 rules.
- If the home came from a §1031 exchange, remember the 5-year ownership requirement before §121 applies — and read the exchange guide.
- If you accumulated suspended passive losses while renting, note they can be released on a qualifying entire-interest disposition to an unrelated buyer under §469(g) — a separate mechanic from the exclusion (and recall §121 excludes gain from gross income rather than making the sale nonrecognition). Bring all of it to your own tax professional before you rely on any of these; §121 is fact-specific.
The bottom line
The home-sale exclusion can still help an accidental landlord, but it isn't automatic and it isn't total. You need two of the last five years as your residence (a real clock once you move out), the post-May-6-1997 depreciation from the rental years is recognized no matter what, and the order — whether you rented before or after living there — decides how much of the gain the exclusion actually reaches. Get the pattern straight before you assume a tax-free sale.

Matt Nunn is the founder of Builders Finance. He has spent two decades working with the financial side of real estate businesses, and started Builders Finance to give short-term-rental operators the financial systems, frameworks, and plain-language education that most hosting advice skips over. Builders Finance publishes educational content for STR owners; it is not legal, tax, or investment advice, treatment depends on your facts and circumstances, and it is not a substitute for guidance from your own qualified professionals.
Continue learning
Depreciation & Gain Character at Sale (Wealth & Exit)
What's still taxed at sale
Concept GuideThe 1031 Exchange (Wealth & Exit)
If an exchange is involved
Decision GuideCan I Actually Use My Rental Losses?
What happens to suspended losses when you sell
The STR Financial Bible
the complete financial system for short-term-rental operators, from underwriting a deal to financing it to structuring it to keeping the books to taxes to the exit. ---
Explore the book →This resource provides general educational information and is not individualized tax advice. The home-sale exclusion, non-qualified use, and the depreciation rules are fact-specific and date-sensitive; consult a qualified professional about your situation.
Primary sources (to place adjacently at build, verified; $250k/$500k figures statutory — confirm current at publish): IRC §121(a)–(b) (2-of-5 test, exclusion amounts); §121(b)(5) (non-qualified use + the post-residence exception); §121(d)(6) (depreciation not excludable, post-5/6/1997); §121(d)(10) (5-year ownership for §1031-acquired property); §469(g) (suspended-loss release at disposition); IRS Pub 523 (Selling Your Home).