If you own a rental property for 20 years, can you then live in your rental property for 2 years and then sell it and get the capital gains exclusion?
Yes. Well, sort of. The exclusion is prorated.
The rental period after 2008 can not be excluded. The depreciation (after May 6th, 1997) also can not be excluded. It is best explained by example (for simplicity, I'm going to use years, but the actual calculation uses days).
Let's say you owed the property for for a total of 22 years, and 9 of those years were rental years after 2008 (2009-2017). You can't exclude those 9 years, but you can exclude the other 13 years. So you can exclude 13/22nds of the non-depreciated gain (59.1%).
Now let's say you paid $100,000 for the home (including any improvements), claimed $60,000 of depreciation, and sold it for $300,000. The $60,000 of depreciation can not be excluded. That is taxed at your regular tax bracket, up to 25%.
For the other $200,000 gain, you can exclude 13/22nds (59.1%) of that gain, or $118,200. The other $81,800 would be taxed at the long-term capital gain rates. That is usually 15%, but the 'extra' income could possibly affect several other things on your tax return, so the net effect could be noticeably more than that.
I'm in a similar scenario however I lived in the property as my primary residence the entire time. Can you please clarify if tax is owed if my primary residence (2 family house no renting) was bought in Nov 2005 converted to 2 condo's in July 2018 and sold 1 unit in Aug 2018. And now the other unit is my primary residence, currently living there now. Would capital gains be owed less the 2 years primary residence versus living in the unit for over 2 years? Thank you!