To claim the exclusion, you must meet the ownership and use tests. This means that during the 5-year period ending on the date of the sale, you must have:
Owned the home for at least 2 years (the ownership test), and
Lived in the home as your main home for at least 2 years (the use test).
Exception. If you owned and lived in the property as your main home for less than 2 years, you can still claim an exclusion in some cases. However, the maximum amount you may be able to exclude will be reduced.
You can exclude up to $250,000 of the gain on the sale of your main home if all of the following are true.
You meet the ownership test.
You meet the use test.
During the 2-year period ending on the date of the sale, you did not exclude gain from the sale of another home.
If you and another person owned the home jointly but file separate returns, each of you can exclude up to $250,000 of gain from the sale of your interest in the home if each of you meets the three conditions just listed.
For full details on Excluding the income from the sale of your main home, see IRS Publicaton 523.