There are a number of legally viable strategies to avoid capital gains on real estate, and in today’s article we’ll show our investors a few of the most popular options.
First, we’ll talk about the primary residence exemption. True to its name, the primary residence exemption only applies to properties that you live in. Even then, there are a number of restrictions and rules that you need to understand if you want to take advantage of this rule.
Second, we’ll inform you about a much lesser-known option: Investing in a Qualified Opportunity Zone. While not as lucrative as either of the other two, it does allow gains to potentially be exempt as well.
Third, we’ll discuss our favorite strategy for avoiding capital gains on real estate: the 1031 exchange. This is an IRS-approved method for completely deferring the capital gains tax as long as you reinvest the proceeds into real estate. Just like the other options, though, it comes with its own set of rules and regulations.
Key Takeaways
- ▸The primary residence exemption lets homeowners exclude up to $250,000 of gain ($500,000 for married couples filing jointly) The owner must generally have lived there for 2 of the last 5 years.
- ▸Opportunity Zone investing defers capital gains for five years (starting in 2027). After a 10 year hold, new growth is tax free.
- ▸A 1031 exchange defers capital gains tax on investment real estate with no dollar cap. It does, however, carry strict 45 and 180 day deadlines.
- ▸Each strategy has its own rules, so ALWAYS consult your CPA to see if that strategy applies to your situation. This is general education only.
First: Tax Avoidance vs. Tax Evasion
First, let’s talk about the legal backdrop around these strategies, since some investors believe (wrongfully) that any form of legal tax avoidance is akin to tax evasion. Even though it should go without saying, all of the strategies on this website are 100% legal and, to the best of our knowledge, in line with current IRS guidelines (although you should always consult with your CPA before making any financial decisions).
But why would the government allow you to not pay capital gains tax? Don’t they want more money?
The reason is simple: The government wants to incentivize spending in certain ways. When investors put money back into the economy through owning shares of a business or buying a commercial real estate property, they fuel the economy in ways that are drastically more net-positive than, say, buying a yacht. Both stimulate the economy, of course, but purchasing a commercial real estate building stimulates the economy much more. That’s why the government gives you a tax break for buying CRE (depreciation benefits) but none for buying a private jet.
In fact, one study shows that investing $1 in CRE stimulates $2.22 in economic return in the form of jobs created (construction, financial services, etc). Nationwide, real estate makes up 18% of GDP.
Put simply: The government wants to incentivize keeping money in real estate because it creates stability for the economy. These strategies do that, which is why the government has written them into the tax code.
With that out of the way, let’s walk through the three options one at a time.
Option #1 for Avoiding Capital Gains on Real Estate: The Primary Residence Exemption
Perhaps the most popular way for most people to avoid paying capital gains on properties is something called the “primary residence exemption.” In order to qualify for this exemption, homeowners need to satisfy a few IRS requirements.
Notice: This may not be very relevant for HNWI and UHNWI investors who are already involved in real estate investing. If that’s you, you’d be better serviced by the two options below; just scroll down.
2-Out-Of-5 Rule
Essentially, if you’ve lived in a property for at least 2 of the last 5 years, you can generally exclude the gain on its sale from your taxable income, up to $500,000 for a married couple and $250,000 if you’re single.
In practice, the IRS applies two tests that pretty much overlap (IRS Topic 701): you need to have both owned the home for two out of the last five years and you need to have lived in the home for two of the last five years. Vacation homes and rental properties don’t count (although that would be nice).
However, while those rules certainly have some overlap, that doesn’t always need to be the case. Let’s say you lived in the property up until three years ago, when you started renting it out. Even though you’ve been living somewhere else for the past three years, you still owned the home for two out of the last five years and owned the home for two of the last five years. You qualify!
Other Rules to Know
Once every 2 years. Homeowners can’t claim the exclusion if they already used it on another home sale within the prior 2 years. Following the example above, you could technically double down on the exclusion in a single calendar year. The government says no.
No vacation homes or second properties. The exclusion covers a primary residence. The IRS typically looks at where the owner spends their most time for people who own several homes. It technically needs to be your “main” home for two of the last five years.
Depreciation is taxable. Remember inputting the square footage of your home office on H&R Block? The government wants that back. Depreciation claimed after May 6, 1997 is generally taxable at sale. That holds even when the rest of the gain is tax free. This doesn’t apply if you 1031 exchange (read option #3).
The Catch on the Primary Residence Exclusion: $500K Total Max
While you can use the primary residence exclusion to avoid capital gains tax, it isn’t infinite. The exclusion caps out at $250,000 if you’re single and $500,000 if you’re married (and filing jointly of course). For the full $500,000, one spouse needs to have owned the property for two of the last five years and both spouses need to have lived there for two of the last five years.
Congress set these limits in 1997 and decided that they don’t need to adjust alongside inflation: They should just stay nominally at $250,000 and $500,000. For reference, $500,00 is worth $1M today — roughly double. As a result, many long term owners in high cost markets like Los Angeles, New York, and virtually any high-cost neighborhood in the US increasingly find that their gain exceeds the cap. As of the current writing, there’s no way around this.
Illustrative scenario:
A married couple bought their home for $400,000. Years later, they sell it for $1,050,000 after selling costs, for a gain of $650,000.
The $500,000 exclusion covers most of that gain, which leaves $150,000 taxable. A high income couple would pay the top 20% federal rate plus the 3.8% net investment income tax. So that remainder could cost roughly $35,700 in federal tax before any state tax.
SCHEDULE A CALL TO LOOK AT NNN PROPERTIES →

Option #2 for Avoiding Capital Gains on Real Estate: Opportunity Zone Investing
Remember what we were saying above about how the government wants to incentivize you to spend money in certain ways to stimulate the economy?
Opportunity Zones are one of those ways. Congress created them in the Tax Cuts and Jobs Act of 2017 to steer money into low income areas.
Then the One Big Beautiful Bill Act, signed on July 4, 2025, made the program permanent and changed its benefits, primarily by changing the date that taxes are deferred to (which used to be Dec. 31st, 2026 across the board).
A Qualified Opportunity Fund is a partnership or corporation that holds most of its assets in Opportunity Zone property. Investors who put a capital gain into one can defer tax on that gain. Investors generally have 180 days from the sale to make that move. After a 10 year hold, new growth on the investment can typically escape federal tax altogether.
How the Benefits Work Starting in 2027
For investments made after December 31, 2026, the deferred gain comes due after five years.
Then, holding for the full five years raises the basis by 10% of the deferred gain. That trims the tax owed but obviously doesn’t eliminate it. Funds that invest in rural Opportunity Zones earn a 30% step up instead (HUD).
After a 10 year hold, investors can step basis up to fair market value. As a result, gains on the investment itself generally avoid federal capital gains tax. Under the new rules, that measurement freezes at the 30th anniversary.
The Current Rules Don’t Make Much Sense: The 2026 Deadline. Currently, gains deferred under the original program come due on December 31, 2026, and they can’t roll into the new program. If you buy a Qualified Opportunity Fund today, it’s still due on December 31st, 2026. It can’t be rolled over into the new program.
The Tradeoffs: Qualified Opportunity Funds are Generally Riskier
Most Qualified Opportunity Zone Funds are new building projects or heavy rehabs. Those usually carry more risk than a stable, leased property. Investors also typically tie up their money for a decade or more. On top of that, investors own a slice of a pooled fund.
Fund fees can also eat into returns, as we’ve written about before.
Option #3 for Avoiding Capital Gains on Real Estate: 1031 Exchanges
A 1031 exchange lets an investor sell investment real estate and defer capital gains tax by reinvesting the proceeds into another investment property.
This is our favorite strategy, and for good reason. Unlike the primary residence exemption, it’s technically infinite. Unlike Opportunity Zones, it doesn’t require you to invest in a pooled fund or a specific neighborhood.
Investors can also repeat it over a lifetime, rolling gains from one property into the next and then pass on that property to their heirs as part of their estate strategy.
Estate planners often call this approach “swap till you drop.” Under current law, heirs generally receive a stepped up basis on inherited property. That can erase the deferred capital gains entirely.
Like-Kind Definition
The phrase “like kind” sounds limited but in actuality it applies to pretty much all real estate in the U.S. Many investors assume that you can only 1031 from a rental property into a rental property, but actually you can 1031 from a rental property into just about anything.
According to the IRS, most real estate counts as “like kind” to other real estate.
A few limits still apply: Both properties must be held for business or investment use, so a primary residence doesn’t qualify. U.S. property also isn’t like kind to property abroad.
Deadlines and Other Rules
As we’ve written in our 1031 exchange guide, there are still a number of strict deadlines and rules you have to follow to successfully pull off a 1031 exchange:
- 45 Day Identification Rule. From the day the original property sells, the investor has 45 calendar days to identify potential replacement properties in writing.
- 180 Day Closing Rule. The replacement property must close within 180 calendar days of the sale (or by the tax return due date, if sooner).
- You Need a Qualified Intermediary. You need to engage a qualified intermediary before you sell the property. This party will hold the sale proceeds. If the sale proceeds hit your bank account, you’re ineligible.
- You’re On the Hook for Any Difference. Let’s say you sell a $1.1M property and buy a $1M property. That extra $100,000 isn’t like kind (known as “boot”) generally triggers tax. To defer the full gain, investors typically buy equal or greater value and reinvest all net proceeds.
Engage a Qualified Intermediary. If the sale money lands in your account, even briefly, the exchange generally fails.
Don’t Wait Too Long to Buy a Property. The 45 day window moves fast. If you can’t identify a property, you fail the 1031 exchange. This could leave you open to MILLIONS in taxes. Don’t make this mistake.
Illustrative scenario:
An investor bought a commercial property for $1,200,000 and sells it for $2,000,000, a gain of $800,000 (ignoring depreciation for simplicity).
In a straight sale, the top 20% federal rate plus the 3.8% net investment income tax comes to roughly $190,400.
With a 1031 exchange into a $2,000,000 replacement property, you don’t have to pay that $190,400 at all. That money simply goes toward the $2M property and you’re done.
That is also why many investors pair a 1031 exchange with absolute NNN real estate.
In an absolute NNN lease, the tenant generally covers taxes, insurance, and maintenance. That keeps landlord responsibilities low while the deferred gain keeps working. We cover this pairing in more detail in why NNN properties make an ideal 1031 exchange replacement.
At Custom Capital, we’ve acquired $460M+ in real estate across 125+ closed deals. Our team focuses on sourcing off market NNN properties, which can help investors move fast once the 45 day clock starts.
Full guide available here: What Is a 1031 Exchange: The Complete Investor’s Guide.
Final Thoughts: How to Avoid Capital Gains on Real Estate
There is no single best way to avoid capital gains on real estate. The primary residence exemption offers a permanent exclusion, but only on a home and only up to $500,000. Opportunity Zones reward patient investors with tax free growth, although they require a long hold in a pooled fund. Meanwhile, the 1031 exchange lets investors defer the full gain and stay in real estate.
Planning a 1031 Exchange?
Talk with our team about sourcing an absolute NNN replacement property that fits your exchange window.
Custom Capital does not provide tax or legal advice. Consult your CPA or tax attorney before making any financial decisions.
Frequently Asked Questions
Can you avoid capital gains tax completely on real estate?
In some cases, yes. The primary residence exemption permanently excludes up to $250,000 of gain ($500,000 for married couples filing jointly) on a qualifying home sale. For investment property, a 1031 exchange defers the tax rather than erasing it. Even so, heirs generally receive a stepped up basis that can eliminate the deferred gain.
How long do you have to live in a house to avoid capital gains?
Generally at least 2 of the 5 years before the sale, under the IRS ownership and use tests. The 2 years don’t have to be consecutive. Owners who sell sooner because of a job change, health reasons, or certain unforeseen events may qualify for a partial exclusion.
Can you do a 1031 exchange on a primary residence?
No. A 1031 exchange only applies to real property held for business or investment. A primary residence falls under the home sale exclusion instead. However, a mixed use property may qualify for each treatment on the matching portion. A CPA should review the details.
What changed with Opportunity Zones in 2026?
The One Big Beautiful Bill Act made the program permanent. For investments made after December 31, 2026, gains defer on a rolling five year clock. Investors also get a 10% basis step up (30% for rural funds) and tax free growth after 10 years. Gains deferred under the original program still come due on December 31, 2026.
What happens if you miss a 1031 exchange deadline?
Generally, the exchange fails and the sale is treated as a normal taxable sale, including any depreciation recapture. The 45 day and 180 day deadlines are strict. Extensions are rare and usually limited to federally declared disasters.
