This special tax treatment is known as the “Section 121 exclusion.”

How Does the Exclusion Work?

The Internal Revenue Service (IRS) requires that, to qualify for the exclusion, you must have owned your property for two of the last five years and lived in it as your main residence for at least two of the last five years preceding the sale date. Suppose you’ve owned and lived in your house for three years. You sell it for $250,000, and your basis in the property is $205,000. You’ll have a capital gain of $45,000. You should not have to pay any federal capital gains tax, because your $45,000 gain is significantly less than the $250,000 exclusion you’re entitled to if you’re a single taxpayer. Your capital gain is therefore tax-free.

Other Rules and Loopholes

The Section 121 exclusion isn’t a one-shot deal. You can effectively sell your residence every two years without owing any capital gains tax on the proceeds, as long as you live there and own it during that time. You just can’t claim the exclusion any more often than once every two years if you’re going to meet these rules. Several other factors can disqualify you, but they’re relatively rare. For example, you can’t have acquired the property through a like-kind 1031 exchange in the last five years, and you can’t be subject to the expatriate tax.

Partial Exclusions

Some taxpayers who sell their residences before meeting the two-out-of-five-years rules might still qualify for a partial exclusion of their gains. The tax code allows taxpayers to exclude a portion of their capital gains if they must sell to relocate for work, because of health issues, or due to other unforeseen circumstances. The following examples could be eligible for a partial exclusion:

The resulting sale of your home is work-related and not something you voluntarily elected to do if your employer transfers you to a position out of town after you’ve lived in your home for just one year. You won’t have to take a big tax hit, but you can’t use the entire $250,000 exclusion.You lived in your home for 50% of the required time if you were in residence for one year. You would therefore multiply 50% by $250,000. The result is that you can exclude a profit of up to $125,000. You would only pay capital gains on any proceeds exceeding this amount.

Members of the military are completely exempt from the two-year rule for up to 10 years if they’re required to move due to service commitments. They must be assigned to a duty station that’s at least 50 miles from their home.

Reporting the Gain

You must still report the gain on your tax return, even if it’s excluded from your income, if you receive a Form 1099-S. The IRS receives a copy of this informational return, too, so you have to let it know that you qualify to exclude the capital gain. You can do this by reporting the income and claiming the exclusion on your tax return. Unfortunately, you can’t deduct capital losses on the sale of personal property—including your home. Only losses on property used for a trade or business are deductible.