It's two of the last 5 years you had to have lived there. There are a lot of other exemptions for partial tax write offs for capital gains as well such as moving for work, illness, divorce, etc. It's complicated and if it's a lot of money you should talk to a cpa.

Originally Posted By: slanddeerhunter
It may have changed but when I rented mine if you rent it over three years without you living in it , you will have to pay capital gains on it when you do sell