Explore the Library
Home Financial Library About Contact

Long-Term RentalsTax Strategy · Concept

The §121 Home-Sale Exclusion When You've Rented Out Your Home

The home-sale exclusion can take up to $250,000 of gain ($500,000 for many couples) out of your taxable income when you sell your principal residence — your main home. If you moved out and rented the place, you may still qualify. But two things decide how much of the exclusion you keep: how long ago you lived there, and whether you rented before or after living in it. And the gain from depreciation taken during the rental years (for periods after May 6, 1997) is never excluded.

Matt NunnMatt NunnFounder, Builders Finance10 min read
On this page6 sections
  1. The two-of-five-year test and the exclusion
  2. Renting after you move out: the clock
  3. The depreciation piece is never excluded
  4. The order of events changes the answer
  5. Two boundaries for investors
  6. Three things govern it
  7. Your action plan
  8. The bottom line

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 a limit if you used the exclusion on another home sale within the two years before this one.
  • If you rent the home out after moving, a clock starts: you generally have a limited window to sell and still qualify — with exceptions for a reduced exclusion and for certain military and government service.
  • The one part §121 never excludes: gain from depreciation for periods after May 6, 1997 during the rental period is recognized at sale. It is measured by the depreciation allowed or allowable, unless your records establish that you claimed less, in which case it is generally what you claimed.
  • The order matters: living there first and renting afterward usually preserves the exclusion, while renting first and moving in later allocates part of the gain to non-qualified use — certain periods when the home wasn't your main home — and that part can't be excluded.

The two-of-five-year test and the exclusion

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. To qualify, you have to pass 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 condition 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. The $500,000 joint-return figure also 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 be excluded from tax.

Renting after you move out: the clock

Now the situation this page is about: you lived in the home, then moved out and rented it — the "accidental landlord," whether because of a job move, a slow market, or choice. The good news is that renting doesn't automatically cost you the §121 exclusion. 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 a rule of thumb, 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. If you miss the ordinary test, you 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 detailed rules. The point here is that being past the window doesn't automatically mean you get no exclusion at all.

The depreciation piece is never excluded

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"). Depreciation you were entitled to take but did not claim still lowers your basis, so it still adds to your gain (§1016(a)(2)). But if your records establish that you claimed less than you were entitled to claim, the part §121 can't exclude is generally measured by what you actually claimed (§121(d)(6) carves out the "depreciation adjustments" defined in §1250(b)(3), and that definition uses the amount allowed where your records establish it was less than the amount allowable). Section 121 does not exclude the gain that comes from depreciation for periods after May 6, 1997. That gain is recognized at sale even when the rest of your gain is fully excluded.

Its character (the kind of gain it is for tax purposes, such as ordinary income or capital gain) follows the usual rules. Depreciation on the building generally produces unrecaptured §1250 gain, which is still capital gain but with its own maximum rate. Any shorter-life §1245 property can produce ordinary recapture, meaning that part is taxed as ordinary income. (The full character mechanics are in Depreciation & Gain Character at Sale.) So the accidental landlord's best case isn't "tax-free." It's the exclusion on the appreciation, but you still recognize the depreciation.

The order of events changes the answer

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, beginning January 1, 2009, when the home was not your principal residence. 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 every case into one of two patterns:

  • 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 part that's easy to get wrong: it does not simply shrink the $250k/$500k ceiling. Instead, you first set aside the depreciation-related gain. The remaining gain is then allocated to non-qualified use, generally by aggregate non-qualified-use time ÷ total ownership period, and that allocated share can't be excluded. In the IRS's own example, two of five ownership years are non-qualified use, so 40% of the remaining gain falls outside the exclusion. So converting a rental into your home and living there two years doesn't get you the whole exclusion; the earlier rental years take 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.

Two boundaries for investors

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. (That kind of exchange, also called a like-kind exchange, is one where you dispose of a property and acquire replacement real property without recognizing some or all of the gain.) And §121 and §1031 can be combined on a property that's been both a residence and a rental, but the mechanics are covered in The 1031 Exchange and Sell, 1031, or Refinance?. Read those before relying on either.

Where does the example rental these guides use 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 rules for gain, basis, and any applicable deferral (including the choice Sell, 1031, or Refinance? compares). §121 is specifically a former-residence rule.

One point is worth noting for any accidental landlord who did build up suspended passive losses while renting. Those are rental losses the passive-loss rules didn't let you deduct, carried forward. §121 is an exclusion, not a nonrecognition provision: the gain is realized and recognized, and then the qualifying gain is excluded from gross income. So a qualifying sale of your entire interest in the activity to an unrelated buyer can still trigger the §469(g) release of suspended losses, even though §121 excludes the home-sale gain. But the excluded gain itself isn't passive income for those losses to offset. The exclusion and the loss release are separate rules that can both show up on the same closing. Can I Actually Use My Rental Losses? and Suspended Losses and the Year You Sell carry the §469(g) detail.

Three things govern it

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 fall outside the five-year window, subject to the reduced-exclusion exceptions.
  • The depreciation carve-out: the gain from the depreciation described above is always recognized.
  • 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.

TAX STRATEGY · §121 AND THE ACCIDENTAL LANDLORD The same two years of renting cost you nothing — or cost you a slice Whether a rental period reduces the exclusion depends on WHEN it happened, not on how long it lasted. GATE · OWNED AND USED AS YOUR PRINCIPAL RESIDENCE ≥ 2 OF THE LAST 5 YEARS? + NO §121 IN THE PRIOR 2 YRS NO ordinary test not met — reduced-exclusion and qualified-duty rules may still apply YES up to $250,000 / $500,000 of exclusion is AVAILABLE — now the carve-outs CARVE-OUT 1 · ORDER OF USE — THE SAME RENTAL PERIOD, TWO PLACES IN TIME residence → rental — you lived there first, then rented LIVED THERE RENTED AFTER time → post-residence rental is generally NOT non-qualified use → the full exclusion survives, if you are in the window rental → residence — you rented first, then moved in RENTED BEFORE LIVED THERE time → that rental period IS non-qualified use (beginning January 1, 2009) → gain allocated by NQ-use ÷ ownership period same length of renting, different position in time — only the second one costs you exclusion CARVE-OUT 2 · DEPRECIATION — POST-5/6/1997, ALLOWED OR ALLOWABLE NOT excludable — always recognized, whatever the order of use character per asset: building GENERALLY feeds unrecaptured §1250, subject to the §1231 process §1245 property → ordinary recapture · mechanics in Wealth & Exit WHAT SURVIVES THE EXCLUSION RENTED AFTER LIVING → generally no non-qualified use — the exclusion holds RENTED BEFORE LIVING → non-qualified use (beginning January 1, 2009) — gain by time ratio DEPRECIATION → recognized either way — it is never excluded A §1031-acquired home needs 5 years of ownership before §121; exchange mechanics route to Wealth & Exit. Tax year 2026 · Source: IRC §121; IRS Pub. 523 (2025) · Reviewed November 2026. Educational model, not tax advice.
Figure Two carve-outs from the exclusion: gain allocated to non-qualified use (depends on the order of use, and is split by time) and gain from depreciation (always recognized). A §1031-acquired home needs 5 years' ownership before §121 applies; the exchange mechanics are covered in the Wealth & Exit guides.
The common mistake

✕ "I lived here two years, so the whole sale is tax-free even though I rented it out." That misses two things. First, the gain from depreciation for periods after May 6, 1997 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 (the rule reaches periods beginning January 1, 2009), and a share of your gain, worked out 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 still has to be met on the sale date, or a reduced-exclusion exception has to apply.

Your action plan

  1. 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.
  2. 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.
  3. Expect to recognize the gain from depreciation for the rental years — generally what was allowable, or what you claimed if your records establish it was less — budget for it; §121 won't cover it, and its character follows the §1245/§1250 rules.
  4. If the home came from a §1031 exchange, remember the 5-year ownership requirement before §121 applies — and read the exchange guide.
  5. If you built up suspended passive losses while renting, note that they can be released under §469(g) on a qualifying disposition of your entire interest in the activity to an unrelated buyer. That's a separate rule from the exclusion; remember that §121 excludes gain from gross income rather than making the sale a nonrecognition transaction. 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, and that becomes a real clock once you move out. The gain from depreciation for periods after May 6, 1997 during 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 writes Builders Finance.

About the author →

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.

The Profitable Real Estate Operator, by Builders Finance

A letter for people who run property as a business. One idea at a time on the financial side of ownership — what changed, what it means, and what an operator should do about it. Written for short-term and long-term rental owners alike.

Free. No spam. Unsubscribe anytime.