Skip to main content
Taxes & Financing

What Is the 2-of-5-Year Rule for the Home Sale Exclusion?

Answered by John Smart, AI-Certified Agent™ Philadelphia Metro Published September 29, 2026 · Updated September 29, 2026 875 words
Short Answer

The 2-of-5-year rule says you can exclude home sale gain if you owned and lived in the home as your primary residence for at least 24 months of the 5 years before the sale. Pennsylvania uses the same general test.

The Test in Plain Terms

The 2-of-5-year rule is the test that unlocks the home sale exclusion. To exclude gain on the sale of your home, you must have owned and lived in it as your primary residence for at least two years, or 24 months, out of the five years immediately before the sale. The two years do not have to be continuous, and they do not have to be the most recent two years, they just have to fall somewhere within the five-year window.

Both ownership and use are required. You can own a home for five years but rent it out for the last three and still qualify if you lived there for the first two. Conversely, living in a home you do not own does not count. The home must be your primary residence during the qualifying period.

How the Two Years Are Counted

The IRS counts time in months and days, not calendar years. You need roughly 730 days of occupancy and ownership within the five-year lookback. Short absences, like a summer vacation or a temporary work trip, still count as time you lived there, but a long absence may not.

If you are close to the threshold and considering a sale, it is often worth waiting until you cross the two-year mark. Selling a few weeks early can mean losing the entire exclusion, while waiting to hit 24 months can save you thousands of dollars in tax.

Pennsylvania Uses a Similar Test

Pennsylvania's principal residence exclusion uses the same general idea. You must have owned and used the home as your principal residence for at least two of the five years before the sale. The state exclusion has no dollar cap, but it generally cannot be used within two years of excluding gain on another principal residence, except for unforeseen circumstances.

So a homeowner who qualifies under the federal rule usually qualifies under the Pennsylvania rule too, and for most people the gain is fully excluded on both returns. The main exceptions are rental or business portions of the home where depreciation was claimed.

When a Partial Exclusion Applies

If you sell before meeting the two-year test, you may still get a partial exclusion if the sale is caused by an unforeseen circumstance, such as a job relocation that requires a move, a health issue, a divorce, or a death in the family. The exclusion is reduced based on how long you actually lived in the home.

For example, a homeowner who lived in the home for one year before a qualifying job move can exclude half of the normal amount. You generally need to document the circumstance, and a tax professional can help you confirm you qualify.

How Often You Can Use It

The exclusion is not unlimited, you can generally use it once every two years. If you sold a home two years ago and used the exclusion, you cannot use it again on a new sale until that two-year window passes, unless an unforeseen circumstance applies.

This matters for people who move frequently. If you are relocating every couple of years, you may not be able to use the exclusion on every sale, and you should plan around the two-year clock.

Smarty's Advice

Before you put a home on the market, check the calendar against the two-of-five-year rule. If you are within a few months of the two-year mark, it is often worth waiting to sell so you keep the full exclusion.

I have helped sellers time their move to preserve the exclusion, and in a strong market the wait rarely costs more than the tax it saves. If you must sell early for a job or health reason, talk to a tax professional about the partial exclusion before you assume the worst.

Call 215-598-6848 or schedule a free consultation, and I will help you plan a sale that keeps your gain protected.

John Smart

Smarty's Advice Expert Insight

John Smart (Smarty) · Smarty Home Solutions / eXp Realty Agent, AI Certified Agent

A few situations cause more confusion than others. The first is renting your home before you sell. If you lived in a home for three years, rented it out for two, and then sell, you still meet the two-of-five-year test because you lived there for three of the five years. But if you rented it for four years and lived there for one, you do not qualify, and the rental years also raise questions about depreciation.

The second is a long absence. If you left the home for a two-year work assignment and rented it out, that time away may not count as use, even if you kept it as your address. The IRS looks at whether it was truly your primary residence during the period.

The third is divorce or a change in ownership. When a home transfers between spouses, the ownership clock generally continues, but a home you inherit or receive as a gift has its own basis and timing rules. If your situation involves renting, an extended absence, or a transfer, have a tax professional confirm you qualify before you rely on the exclusion. The rule is simple for the straightforward case, and nuanced for everything else.

Finally, do not assume the two years reset automatically when you move. If you sell one home, buy another, and sell again within two years, you generally cannot use the exclusion on the second sale. Plan your timing so you do not accidentally forfeit the exclusion you have earned.

John Smart

Answered by John Smart

AI-Certified Agent™ with eXp Realty | PA License RS348332

Serving Philadelphia, Montgomery, Bucks, Chester, Delaware & Berks Counties

Have Another Question?

Contact John Smart for personalized answers about your real estate situation. No obligation, just honest advice.

John Smart | AI-Certified Agent™ | License RS348332 | eXp Realty