How to Avoid Capital Gains Tax on Real Estate: Section 121 and 1031

Five legal strategies can shrink or wipe out the capital gains tax on real estate: the primary residence exclusion, a 1031 like-kind exchange, adding capital improvements to your cost basis, the stepped-up basis on inherited property, and an installment sale that spreads the gain across tax years. Which one fits depends on whether the property is your home, an investment, or something you inherited, and each has rules that will disqualify you if you miss them. Knowing how to avoid capital gains tax on real estate starts with matching the strategy to the property.

What You’re Actually Trying to Avoid

Federal tax on real estate profit depends on how long you owned the property. Hold it a year or less and the gain is taxed at ordinary income rates, which run from 10% to 37% for 2026.1Internal Revenue Service. IRS Releases Tax Inflation Adjustments for Tax Year 2026 Hold it longer than a year and the gain qualifies for long-term rates of 0%, 15%, or 20% depending on your taxable income.2Internal Revenue Service. Topic No. 409, Capital Gains and Losses Higher earners also pay a 3.8% Net Investment Income Tax when modified adjusted gross income tops $200,000 single or $250,000 married filing jointly, pushing the effective top federal rate to 23.8%.3Office of the Law Revision Counsel. 26 USC 1411 – Imposition of Tax

Rental owners face something extra. Depreciation you claimed (or were entitled to claim) on the property gets recaptured at sale, taxed at up to 25% rather than the standard long-term rates.4Office of the Law Revision Counsel. 26 USC 1 – Tax Imposed Skipping the deduction on your returns doesn’t help. The IRS treats depreciation as reducing your basis whether you claimed it or not.5Internal Revenue Service. Publication 527 (2025), Residential Rental Property That’s why the deferral strategies below matter so much for landlords.

Sell Your Main Home: The Section 121 Exclusion

If the property is your primary residence, this is the single most valuable break. A single filer can exclude up to $250,000 of gain from the sale; a married couple filing jointly can exclude up to $500,000.6Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence For most homeowners, that erases the tax entirely.

The Two-Year Tests

You have to pass two tests during the five years before the sale. You must have owned the home for at least two of those five years, and you must have lived in it as your main home for at least two of those five years. The 24 months don’t need to be consecutive. You can only use the exclusion once every two years.6Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence Joint filers claiming the full $500,000 both need to meet the use test, but only one spouse needs to meet the ownership test.

Partial Exclusion for Job, Health, or Unforeseen Moves

Selling before hitting two years doesn’t automatically kill the break. A qualifying job relocation, health condition, or other unforeseen circumstance gets you a proportional exclusion. The IRS multiplies the fraction of the two-year period you actually lived in the home by the full $250,000 or $500,000 cap. A single seller who lived in the home 15 months before a qualifying job change could exclude roughly $156,250.6Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence

The Nonqualified Use Trap for Converted Rentals

If you turned a rental into your home so you could use the exclusion, read this carefully. Any period after January 1, 2009, when the property wasn’t your primary residence counts as nonqualified use, and the share of your gain tied to that period doesn’t qualify.7Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence Renting a home for four years, moving in for two, then selling still leaves the rental-period gain taxable. Meeting the use test opens the door but doesn’t erase the rental history.

The Military and Foreign Service Extension

Service members, Foreign Service officers, and intelligence community personnel on qualified extended duty can elect to suspend the five-year test period for up to 10 years.7Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence That means a two-year stay followed by an eight-year deployment can still end in a full-exclusion sale.

Trade Investment Property: The 1031 Exchange

For investment or business real estate, Section 1031 lets you swap one property for another like-kind property without recognizing the gain.8Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment The exclusion eliminates tax; a 1031 defers it. The deferred gain rides with the replacement property.

Like-kind is broader than most people expect. You can exchange an apartment building for vacant land, a warehouse, or a strip mall. Both properties just need to be held for investment or business use. Since the Tax Cuts and Jobs Act took effect in 2018, Section 1031 covers real property only. Equipment, vehicles, and other personal property no longer qualify.9Internal Revenue Service. Like-Kind Exchanges – Real Estate Tax Tips

The 45- and 180-Day Deadlines

From the day the original sale closes, you have exactly 45 days to identify potential replacement properties in writing, and 180 days total to close on the replacement (or the due date of your return for that year, including extensions, whichever comes first).8Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment Missing either date by a day kills the whole deferral.

You Can’t Touch the Money

A qualified intermediary must hold the sale proceeds and apply them to the replacement purchase at closing. If the funds pass through your hands or your bank account, even briefly, the IRS treats the whole thing as a taxable sale. The intermediary also handles the identification paperwork and closing coordination.

Vacation Homes Need Real Rental History

A property used mainly for personal enjoyment isn’t held for investment and doesn’t qualify. The IRS created a safe harbor for vacation homes that are genuinely rented: the property must be rented at fair market rates for at least 14 days in each of the two 12-month periods before the exchange, and your personal use in each period can’t exceed the greater of 14 days or 10% of rental days.10Internal Revenue Service. Revenue Procedure 2008-16 The same limits apply to the replacement property for the two years after the exchange.

Reporting

File IRS Form 8824 with your return for the year of the exchange, listing both properties, identification and closing dates, and values.11Internal Revenue Service. Instructions for Form 8824 (2025) Any cash or non-like-kind property you receive as part of the deal (called boot) stays taxable even though the rest of the gain is deferred.

Raise Your Cost Basis With Improvements

Every dollar you add to your cost basis is a dollar off your taxable gain. Basis starts with the purchase price plus qualifying closing costs like legal fees, recording fees, owner’s title insurance, and transfer taxes.12Internal Revenue Service. Publication 523 (2025), Selling Your Home Capital improvements during ownership add to it from there.

A capital improvement adds value, extends the property’s useful life, or adapts it to a new use. The IRS lists examples like new roofing, central air conditioning, heating systems, swimming pools, additions, kitchen remodels, and security systems. Routine maintenance doesn’t qualify. Painting, patching cracks, fixing faucets, and replacing broken hardware are upkeep, not improvement.12Internal Revenue Service. Publication 523 (2025), Selling Your Home

Practical advice: keep every invoice, permit, and receipt from the day you close. A $40,000 kitchen renovation and a $15,000 roof replacement add $55,000 to your basis, which is $55,000 less taxable gain at sale. Records you can’t produce at audit are worth nothing.

Rental owners have a harder time here because depreciation cuts basis the other direction, and the recaptured portion is taxed at up to 25%.4Office of the Law Revision Counsel. 26 USC 1 – Tax Imposed That’s why many landlords pair improvement tracking with a 1031 exchange at sale: the exchange defers both the standard gain and the recapture, while the improvements reduce the deferred gain carried into the next property.

Inherit the Property: Stepped-Up Basis

When someone dies and leaves real estate to an heir, the property’s basis resets to its fair market value on the date of death.13Office of the Law Revision Counsel. 26 USC 1014 – Basis of Property Acquired From a Decedent All the appreciation during the original owner’s lifetime disappears for tax purposes. A parent who bought a house for $80,000 thirty years ago and leaves it to a child when it’s worth $550,000 hands the child a basis of $550,000. Sold soon after for $560,000, the taxable gain is $10,000.

This is why inherited real estate is treated very differently from gifted real estate. A gift carries over the donor’s original basis, so the recipient inherits the tax liability along with the property. An inheritance resets the clock. Get a professional appraisal near the date of death and keep it with the property records.

The step-up is also the long-term exit strategy for 1031 investors. Chain exchanges for decades, defer the gain each time, hold the final property until death, and the heirs receive a stepped-up basis that erases the accumulated deferred gain. What was technically a deferral becomes permanent elimination. In community property states, the basis of the entire jointly held property (not just the deceased spouse’s half) can reset at the first spouse’s death, making the benefit even larger.14Internal Revenue Service. Publication 555, Community Property

Spread the Gain: Installment Sales

When none of the four methods above fully applies, an installment sale softens the hit. Receive payments over multiple tax years instead of a lump sum, and you report only the share of gain tied to each year’s payment.15Internal Revenue Service. Publication 537 (2025), Installment Sales The IRS uses a gross profit percentage to split each payment between taxable gain and tax-free return of basis. Spreading payments across years can hold you in a lower bracket and keep you under the 3.8% Net Investment Income Tax thresholds. It doesn’t eliminate the tax, but for sellers who can’t qualify for a 1031 or the primary residence exclusion, it can meaningfully reduce the total.