Sell rental property you moved out of and lived in — no capital gains?

Trying to figure out if I can avoid capital gains on a property I originally bought as my primary home, lived in for about 3 years, then moved out and rented for the last 2 years before selling this past spring. Total gain is significant. I keep reading about the home sale exclusion but everything I find talks about it like you either lived there or you didn't. I did live there — just not recently. Already looked at the ownership and use test rules but the 5-year lookback window is confusing me. Does the time I actually lived there count even though it was a rental when I sold it? And does depreciation I took while renting change anything about what I can exclude?

35 comments

The short answer is yes, your years of residence count — but with important limits. The exclusion under the home sale rules requires you to have owned and used the home as your main residence for at least 24 months out of the 5 years before the sale. The 24 months don't need to be consecutive, so your earlier years living there count. If you meet that test and haven't excluded gain on another home in the prior 2-year period, you can potentially exclude a large portion of the gain. The complication is depreciation: any depreciation you claimed or could have claimed during the rental period is not eligible for the exclusion — it's taxed separately as unrecaptured section 1250 gain. So the exclusion won't wipe out everything. Check Publication 523 on irs.gov for the exact eligibility steps.

Raj K.

Author

This is exactly what I needed to understand — that the 24 months can be pulled from anywhere in the 5-year window. The depreciation piece is the part I hadn't fully processed. So I'd still owe tax on whatever depreciation I took even if the rest of the gain is excluded?

Correct. The depreciation recapture portion — what the IRS calls unrecaptured section 1250 gain — comes out before you apply the exclusion to the remaining gain. It's taxed at a different rate than regular long-term capital gains. Your Schedule D and the Unrecaptured Section 1250 Gain Worksheet in the Schedule D instructions walk through the calculation.

Lived in my place 2.5 years before renting it out for 18 months, then sold. Had the same question. The 5-year window saved me — my residence period was recent enough that I cleared the 24-month ownership and use tests. The IRS eligibility test in Publication 523 has a step-by-step checklist; I went through each step before filing.

Raj K.

Author

Good to know the window can still work even after a rental period. My 3 years of living there all fall within the 5-year lookback from my sale date so I should be in good shape on the use test.

One thing to be careful about: if you acquired this property through a section 1031 like-kind exchange within the 5 years before the sale, the exclusion is off the table entirely regardless of how long you lived there. Just flagging it because a lot of rental property owners have done 1031s and don't realize it blocks the exclusion.

Raj K.

Author

No 1031 in my history on this one — bought it straight. But that's a really important flag for anyone who exchanged into a property and then moved in.

I sold a property in a similar situation last year. I uploaded all my closing documents and depreciation schedules to taxr.ai and had it map out which portion of my gain was excludable, which was depreciation recapture, and what actually needed to go on Form 8949. It flagged that I needed to report the sale on Form 8949 even though most of the gain was excluded, and drafted the worksheet showing the excluded amount in column (g) with code H. Saved me from just skipping the form entirely because I thought I owed nothing.

Had a similar situation and almost skipped reporting it too. The fact that you still have to put it on Form 8949 when you receive a Form 1099-S is something a lot of people miss.

Exactly — and even without a 1099-S, the depreciation recapture piece means there's something taxable to report regardless. The worksheet made the split obvious.

The Form 8949 reporting piece is worth spelling out. If you received a Form 1099-S at closing, you must report the sale on Form 8949 Part II even if the entire remaining gain after recapture is excluded. You check box F (long-term transactions not reported to you on Form 1099-B, which is the box for a home sale that came on a 1099-S), enter code H in column (f), and put the excluded gain as a negative number in column (g). The taxable depreciation recapture flows separately through the Unrecaptured Section 1250 Gain Worksheet.

Raj K.

Author

I did receive a 1099-S, so I definitely need to file Form 8949. This breakdown of which box and which code is exactly what I was missing.

Worth double-checking: box F on the 2025 Form 8949 is for long-term transactions not reported to you on Form 1099-B, which covers a home sale that came on a Form 1099-S. The instructions for Form 8949 at irs.gov lay out which box applies to which situation.

Does the holding period on the rental portion affect anything? Like does the IRS treat part of the property as having a different holding period because it was a rental?

For the home sale exclusion calculation, the IRS doesn't split the property into separate holding periods based on rental vs. residence use. The whole property's gain is considered together, then you carve out the depreciation recapture and apply the exclusion to the rest. The holding period for long-term treatment is based on how long you owned the property total — more than 1 year means long-term.

Worth noting that the exclusion limits differ by filing status. Single filers and married filing jointly filers have different maximum exclusion amounts. Publication 523 has the figures. Also the ownership test and use test work slightly differently for joint filers — only one spouse needs to meet ownership but each must independently meet the use test.

Raj K.

Author

Filing single in my case so the single-filer limit applies. Good to know the ownership vs. use test split for married couples though — that comes up for a lot of people.

When I sold my old primary home that I'd rented out for a couple of years, I ran the numbers three different ways and kept getting confused about where the depreciation recapture ended and the excludable gain began. I gave Taxr my depreciation schedule and the closing statement and it walked through the calculation step by step — recapture first, then the remaining gain against the exclusion limit, then what actually goes on Schedule D. Really clarified the order of operations for me.

Raj K.

Author

The order of operations is what's been tripping me up too. Recapture first, then exclusion on the rest — that's the sequence I needed confirmed.

Right, and the recapture amount becomes unrecaptured section 1250 gain on Schedule D, taxed at its own rate. It doesn't just fold into the excluded chunk.

What if you didn't actually claim depreciation during the rental years — does the recapture still apply? I've seen people say you get hit on depreciation you "could have" claimed even if you didn't.

That's correct. The IRS taxes you on depreciation allowed or allowable — meaning the amount you were entitled to claim, whether or not you actually took it. If you skipped depreciation deductions during the rental period, you generally don't get out of the recapture; the allowed-or-allowable rule applies. If you think you underreported depreciation, you can file Form 3115 to catch up, which may actually reduce your taxable gain on the sale.

That's a painful rule. So not claiming it doesn't protect you, it just means you gave up the deductions without avoiding the recapture hit on sale.

The partial exclusion is also worth knowing about. If you don't meet the full 24-month use test — say you only lived there 18 months — you may still qualify for a partial exclusion if the main reason for selling was a job location change, a health issue, or what the IRS calls an unforeseeable event. Publication 523 describes how the partial amount is calculated as a fraction of the full exclusion.

Raj K.

Author

I do clear the full 24-month test so this doesn't apply to me, but good to know the partial exclusion exists for cases where the timeline is tighter.

Curious whether the 2-year lookback on prior exclusions could be a problem for anyone who sold another home recently. If you excluded gain on a different property in the 2 years before this sale, you're disqualified from using the exclusion again even if you otherwise meet the ownership and use tests.

Raj K.

Author

This was my only property so not an issue, but that 2-year cooldown is easy to forget if someone is rolling from one home to the next.

I uploaded my sale documents and old depreciation records to Taxr and had it prepare the Unrecaptured Section 1250 Gain Worksheet alongside the Form 8949 entry. It laid out the recapture amount, the remaining gain, the excluded portion, and what flowed to Schedule D line 19. Helped me confirm I wasn't double-counting the excluded gain against the recapture.

Schedule D line 19 is where the unrecaptured 1250 gain lands — that's the part a lot of people overlook when they think the exclusion covers everything.

To flag a timing point: the holding period for long-term capital gains treatment starts the day after you acquired the property, and the day you sold it counts as part of the holding period. For properties traded on an established market the trade date is what matters, not settlement. For real estate you're looking at closing dates. If you've owned the property for more than 1 year total — which almost certainly applies here — the gain (excluding the recapture piece) qualifies as long-term.

Is there any state-level version of this exclusion that mirrors the federal one? Or does each state do its own thing completely?

Each state does its own thing. Many states conform to the federal exclusion but some have their own limits or add-backs. That's outside what this community tracks — a CPA or enrolled agent in your state can confirm how your state treats the gain.

The IRS topic page on capital gains and losses (Topic 409) is also worth reading alongside Publication 523 — it covers the long-term vs. short-term distinction and the Schedule D flow in plain language. Both are on irs.gov.

Bottom line for the original situation: 3 years of residence within the 5-year lookback clears the ownership and use tests. The gain attributable to unrecaptured depreciation gets taxed regardless of the exclusion. The rest of the gain up to the applicable exclusion limit is excluded. If a Form 1099-S was issued, report the sale on Form 8949 Part II with code H and the excluded amount as a negative in column (g). Depreciation recapture flows through the Unrecaptured Section 1250 Gain Worksheet to Schedule D.

Raj K.

Author

This is exactly the summary I needed. I'll work through Publication 523 for the eligibility steps and the Schedule D instructions for the recapture worksheet. Really appreciate everyone walking through the details.