Does moving back into rental property for two years avoid capital gains tax?

I've owned a house for about 8 years, rented it out for the last 5. Now I'm thinking about moving back in for two years before I sell. My understanding is that if I live there as my primary residence for 2 of the last 5 years before the sale, I can exclude the gain. But I've also heard there are limits when the property was used as a rental, something about depreciation recapture and a nonqualified use calculation? I did claim depreciation every year on Schedule E. The gain would be substantial. I'm trying to figure out if moving back in actually helps or if I'm kidding myself. Has anyone done this or worked through the numbers on it?

34 comments

Moving back in does help, but it doesn't eliminate everything. You can meet the ownership and use test — 2 of the last 5 years — which lets you exclude up to the standard exclusion amount for your filing status. The problem is two things survive no matter what: depreciation recapture and the nonqualified use fraction. The depreciation you claimed on Schedule E gets recaptured as ordinary income (up to 25% rate) when you sell, and moving back in does not erase that. Those years of rental use before you returned are also "nonqualified use" under the tax code, and the gain attributable to that fraction is not eligible for the exclusion. See Topic no. 701 and Publication 523 at irs.gov for the specifics.

Beth C.

Author

So even if I satisfy the 2-out-of-5 test, part of the gain is still taxable because of those rental years before I moved back? That's the part I wasn't clear on.

Exactly. The nonqualified use period is roughly the rental years divided by your total ownership, applied to the total gain. Only the remaining portion of gain — after backing out the nonqualified use share — is eligible for the exclusion. Depreciation recapture is calculated separately on top of that.

Worth noting: the 2-out-of-5 window looks backwards from your sale date. So if you move in now and sell exactly 24 months later, you just barely clear it. But if you delay the sale even a little and your rental years fall outside that 5-year window, the math shifts. Timing the sale date carefully matters a lot here.

Beth C.

Author

Does the 2 years have to be continuous or can it be two separate periods that add up to 24 months?

It doesn't have to be continuous. Publication 523 says the 24 months don't have to be one block, just within the 5-year lookback period. So if you lived there earlier and then rented it, those earlier months can count toward the use test.

I worked through almost the same situation last year — rental for several years, moved back, then sold. I uploaded my depreciation schedules and the sale closing statement to taxr.ai and it built out a worksheet showing the nonqualified use fraction, the excludable gain, and the depreciation recapture amount separately. Really helped me see the actual taxable number before I filed. The recapture piece was the part I kept underestimating. It is taxed as ordinary income up to a 25% rate regardless of how long you held the property.

Beth C.

Author

How did it handle the depreciation recapture — did it pull the numbers from the Schedule E history?

The nonqualified use rule is worth spelling out clearly. Any period of rental or other non-personal use after 2008 and before you move back in counts as nonqualified use. Periods within the 5-year window after your last day of personal use do not count. The fraction is: nonqualified use days divided by total ownership days, multiplied by total gain. That portion is not excludable even if you meet the residence test perfectly.

What about the period after you move out at the end before selling? Does a gap between moving out and closing count as nonqualified use?

Post-residency periods between when you stop living there and when you close the sale generally do not count as nonqualified use, as long as they fall within the 5-year period after your last day of residence. You still need to close in time to keep meeting the 2-out-of-5 use test, though, so don't let the property sit vacant too long.

Depreciation recapture catches a lot of people off guard. Every year you claimed depreciation on Schedule E reduced your cost basis in the property. When you sell, the IRS recaptures that accumulated depreciation as Section 1250 gain taxed at ordinary rates up to 25%, separate from the long-term capital gain. Moving back in does not undo any of that. The number to track down is the total depreciation you've claimed since you started renting.

Beth C.

Author

I have all my prior Schedule E returns. I can add up the depreciation claimed each year. Is that the right number to use for recapture, or is there a specific line I should check?

The depreciation recapture amount on sale flows through Form 4797 for unrecaptured Section 1250 gain. Your broker won't handle this — it comes from your own records of what was claimed. The accumulated depreciation from your Schedule E history is what you need. That total gets reported and taxed at the special 25% rate (or your ordinary rate if lower). Don't confuse this with the capital gain on the appreciation above your original basis.

I'd push back slightly on the idea that moving back in is pointless. Even with the nonqualified use fraction and the recapture, the exclusion still shelters a meaningful portion of the appreciation that happened during your personal use periods. For a property with substantial gain the math can still favor moving back in versus selling straight from rental status.

Agreed, it's not pointless. The question is whether the gain attributable to qualifying use is large enough to make it worth the cost and disruption of actually living there for two years. Run the numbers both ways.

One thing that affects the calculation: what was your basis when you started renting? If you converted from personal use to rental, your depreciable basis was the lower of FMV at conversion or your adjusted cost basis. That matters for figuring out how much depreciation you should have claimed, which in turn affects recapture.

Beth C.

Author

I bought it as a primary residence first, lived there a couple years, then converted it to rental. So I'd use the lower of FMV at conversion or cost basis for the depreciation base, right?

Right. And if FMV was lower at conversion, you've been depreciating a smaller base, so your recapture amount is lower too. But your gain on sale is still measured from your original cost basis minus all depreciation actually claimed.

The 5-year window is easy to misread. It's the 5 years ending on the sale date, not 5 years from when you moved back. So if you move back in January 2025 and sell in March 2027, your 5-year window runs March 2022 to March 2027. The rental years from 2020 and 2021 fall outside that window entirely. Those outside-window rental years still count as nonqualified use but don't affect your ability to meet the use test.

Has anyone looked at whether a 1031 exchange out of the rental first would have been cleaner? If you had exchanged into another rental property and then moved into that one later, the rules are different and arguably tighter — there's a 5-year hold requirement after a 1031 to even be eligible for the home sale exclusion. So that path has its own traps.

The 5-year rule after a 1031 is real. Publication 523 covers it — property acquired through a like-kind exchange within the previous 5 years isn't eligible for the exclusion. So 1031 into a rental and then immediately move in doesn't work.

I ran into the nonqualified use issue on my own sale. Had the property on Form 4797 and Schedule D both showing amounts and I wasn't sure which part was the recapture versus the capital gain. I pasted my return draft into Taxr and it walked through which lines tied to which — the unrecaptured 1250 gain showing up in the Schedule D worksheets versus the recapture itself. Really helped me confirm the numbers were landing in the right places before I signed.

Beth C.

Author

Did you need to file Form 8949 for the home sale even though part of it was excluded?

In my case I did receive a Form 1099-S, so yes — Publication 523 says if you got a 1099-S you have to report the sale on Form 8949 regardless of whether you have taxable gain. Used code H in column (f) and put the excluded amount as a negative in column (g).

If the gain is large enough that even after the exclusion and after backing out nonqualified use you're still looking at significant taxable gain, it might be worth sitting with a CPA or enrolled agent before you move back. The move itself has real costs and locking yourself into a two-year residence to get a partial tax benefit deserves a projected number first.

I had a similar rental-to-residence conversion and was unsure how to split the gain between the qualifying and nonqualified portions on my return. I gave Taxr my Schedule E history, the closing statement, and my original purchase records, and it prepared a worksheet breaking down the nonqualified use fraction, the excludable portion, and the recapture — all labeled so I could hand it to my CPA to review before filing. Saved a lot of back-and-forth.

Beth C.

Author

That's basically what I need. I want to understand the numbers before deciding whether the move even makes sense financially.

Something to flag: the holding period for capital gains purposes on the whole property is long-term since you've owned it 8 years, so the non-excluded, non-recapture portion of the gain gets long-term rates. Only the unrecaptured Section 1250 piece gets pushed up to the 25% ceiling. The rates themselves turn on your overall income — check the Schedule D instructions for the Schedule D Tax Worksheet.

Don't forget state taxes. A lot of states don't conform to the federal home sale exclusion, or they conform but have different limits. If you're in one of those states, the federal exclusion gives you nothing at the state level and the full gain could be taxable there. Worth checking your state's rules separately.

Which states don't conform? I assumed they all matched federal on this.

Most do conform but not all, and conformity details change. Your state's department of revenue website is the right place to check — the IRS rules only cover federal tax.

Pulling back to the original question: moving back in for two years does avoid capital gains tax on the qualifying portion of the gain, but it doesn't avoid depreciation recapture and it doesn't shelter the nonqualified use share of the gain. Whether the exclusion on the remaining portion is worth two years of living there is a math problem specific to your numbers — total gain, years of rental use, depreciation claimed, and your tax bracket.

Beth C.

Author

This thread answered it better than anything I found elsewhere. I'm going to build out the worksheet with my actual numbers before making a decision. Thanks everyone.