There is no single trick to avoid paying capital gains tax on property, but the tax code offers several legitimate ways to exclude, defer, or shrink the bill depending on what you’re selling. Homeowners have the Section 121 exclusion. Rental and investment property owners have Section 1031 exchanges, installment sales, and Opportunity Zone funds. Everyone benefits from carefully tracking basis, timing losses against gains, and understanding what happens if property is held until death. The right combination hinges on the type of property, how long you’ve owned it, and what you plan to do with the proceeds.
One warning before the strategies: if the property is a rental or has otherwise been depreciated, part of your gain is taxed as depreciation recapture at up to 25%, and most of the tools below do not fully solve that problem. More on that at the end.
Sell a Home You’ve Lived In: The Section 121 Exclusion
The most generous tool in the code is for homeowners. Section 121 lets you keep up to $250,000 of profit from selling your main home completely tax-free, or up to $500,000 for a married couple filing jointly. Any gain above those amounts is taxed at the applicable capital gains rate.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence
To qualify for the full amount, you need to pass two tests within the five-year window ending on the sale date. The ownership test requires you to have owned the property for at least two years during that window. The use test requires you to have lived in it as your principal residence for at least two years during the same window. The two years don’t need to be consecutive; you could live there for 14 months, move out, come back for 10 months, and still qualify.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence
You can only claim the exclusion once every two years. If you used it on a previous sale, wait.
Partial Exclusions for Early Sales
If you sell before hitting the two-year marks because of a job relocation, a health condition, or another unforeseen circumstance defined in IRS regulations, you can still claim a partial exclusion prorated by how much of the two-year requirement you actually met.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence A married couple who lived in the home for 12 of the required 24 months, for instance, would qualify for half: $250,000 instead of $500,000.
Military and Foreign Service Extension
Members of the uniformed services, the Foreign Service, and the intelligence community can suspend the five-year lookback period for up to 10 additional years while on qualified extended duty, effectively stretching it to 15 years.2Office of the Law Revision Counsel. 26 U.S. Code 121 – Exclusion of Gain From Sale of Principal Residence A service member stationed overseas for a decade can still sell a stateside home and claim the full exclusion, as long as the two-year use requirement was met at some point during the extended window.
Section 121 is a homeowner tool. It does not apply to rental buildings, commercial property, or vacant land held for investment.
Swap Investment Property: The 1031 Exchange
For rental, commercial, or investment real estate, Section 1031 lets you swap one property for another of “like kind” and defer the entire capital gains bill. The gain rolls into the replacement property’s basis rather than being recognized, so no tax is due until you eventually sell without doing another exchange.3Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment Some investors chain exchanges for decades.
“Like-kind” is broader than it sounds. Virtually any investment or business real estate qualifies for any other investment or business real estate: an apartment building for a retail strip, a farm for an office park, raw land for a warehouse. What doesn’t qualify is property held primarily for resale (a flip), your personal home, or non-real-estate assets like stocks or partnership interests.3Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment
Don’t Touch the Money
A qualified intermediary must hold the funds from the sale of the old property and use them to purchase the replacement. If you take control of the cash, even briefly, the IRS treats the whole thing as a taxable sale.4Internal Revenue Service. Like-Kind Exchanges Under IRC Section 1031 This is the single most common way people accidentally blow up an exchange.
Two Deadlines That Cannot Slip
Two clocks start on the day you close on the sale of your relinquished property. You have 45 calendar days to formally identify potential replacements in writing. You then have 180 calendar days from that same closing date to complete the purchase.3Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment These deadlines are absolute. They do not extend for weekends, holidays, or natural disasters. Miss either one and the entire deferred gain becomes immediately taxable.
When identifying properties, you can list up to three potential replacements regardless of value. If you want to list more than three, the combined fair market value of everything on the list cannot exceed 200% of the value of the property you sold.
Watch for Boot
If the replacement property costs less than what you sold the old one for, or you receive cash or debt relief that isn’t offset by new debt, the difference is called “boot.” You pay capital gains tax on the boot but still defer the rest.3Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment For a full deferral, the replacement needs to be equal to or greater in value, and your new mortgage needs to cover or exceed the old one.
Raise Your Basis and Cut Your Sale Price
Whether or not you use one of the bigger strategies, you can shrink the taxable gain by properly accounting for every dollar you’ve invested in the property and every dollar it took to sell.
Capital improvements add directly to your basis. Anything that materially adds value or extends the life of the property counts: a new roof, an addition, central air conditioning, a rewired electrical system, a paved driveway.5Internal Revenue Service. Publication 551 (12/2025), Basis of Assets Routine maintenance and minor repairs don’t qualify. Replacing a broken window is a repair; replacing all the windows in the house is an improvement.
Closing costs from your original purchase also increase your basis. Title insurance, legal fees, recording fees, transfer taxes, and survey costs all count.5Internal Revenue Service. Publication 551 (12/2025), Basis of Assets Loan origination fees and mortgage-related charges do not. Keep every settlement statement and every improvement receipt. If you’re audited, the IRS will want documentation.
On the other side of the ledger, selling expenses reduce the “amount realized” from the sale. Real estate agent commissions, advertising costs, legal fees, transfer taxes you paid as the seller, and other direct costs of the sale all qualify.6Internal Revenue Service. Publication 523 (2025), Selling Your Home On a $500,000 sale with a 5% commission, that’s $25,000 knocked off your gain before any other strategy applies.
Offset the Gain With Capital Losses
If you sell property at a gain in the same year you sell other investments at a loss, those losses directly offset the gain. Sell a stock portfolio down $80,000 in the year you sell a rental property with a $200,000 gain, and your net taxable gain drops to $120,000.
If your total capital losses for the year exceed your total capital gains, you can deduct up to $3,000 of the net loss against ordinary income ($1,500 if married filing separately). Unused losses carry forward indefinitely.
One advantage for real estate: the wash sale rule, which prevents claiming a loss on stock if you buy back a substantially identical investment within 30 days, does not apply to real property. The statute covers only shares of stock and securities.7Office of the Law Revision Counsel. 26 U.S. Code 1091 – Loss From Wash Sales of Stock or Securities You could sell a rental at a loss and buy a similar property the next day without jeopardizing the deduction.
Spread the Gain With an Installment Sale
When you sell property and carry the financing yourself rather than taking a lump sum, you can report the gain under the installment method. Instead of paying tax on the entire profit in the year of sale, you recognize a proportional share of the gain as each payment arrives.8Office of the Law Revision Counsel. 26 USC 453 – Installment Method
The IRS calculates a “gross profit percentage” for the sale. If your total gain is 40% of the contract price, then 40% of each principal payment is taxable as capital gain and the rest is a tax-free return of basis. Interest on the note is taxed separately as ordinary income. The sale is reported on Form 6252.
Spreading the gain over years can keep your annual income within a lower capital gains bracket and reduce exposure to the 3.8% net investment income tax. The trade-off: you’re spreading your cash flow over years too, and taking on the credit risk that the buyer stops paying.
A critical catch for rental property: depreciation recapture cannot be deferred through the installment method. The entire recapture amount is taxed in the year of sale regardless of when the payments arrive.8Office of the Law Revision Counsel. 26 USC 453 – Installment Method
Reinvest Through a Qualified Opportunity Fund
If you reinvest a capital gain from any source into a Qualified Opportunity Fund within 180 days of the sale, you can defer the tax on that gain.9Office of the Law Revision Counsel. 26 U.S. Code 1400Z-2 – Special Rules for Capital Gains Invested in Opportunity Zones The fund must invest in designated low-income census tracts. Under current law, you must recognize the deferred gain no later than December 31, 2026, at which point tax comes due on the lesser of the original deferred gain or the current fair market value of your fund investment.10Internal Revenue Service. Opportunity Zones Frequently Asked Questions
The bigger prize is the 10-year exclusion. If you hold the fund investment for at least 10 years, any appreciation in the fund’s value above your original investment can be excluded from tax entirely. The IRS adjusts your basis in the fund to fair market value on the sale date, so the growth is never taxed.10Internal Revenue Service. Opportunity Zones Frequently Asked Questions It is one of the few mechanisms that can permanently eliminate capital gains tax on new appreciation.
Timing matters. The election to defer gains into a Qualified Opportunity Fund cannot be made for any sale occurring after December 31, 2026.9Office of the Law Revision Counsel. 26 U.S. Code 1400Z-2 – Special Rules for Capital Gains Invested in Opportunity Zones Because deferred gains are recognized by year-end 2026 regardless, the deferral benefit for new investments is minimal. The real remaining value is the 10-year appreciation exclusion for investors willing to hold that long. Legislation may modify these rules, so check current status before committing.
Charitable Remainder Trusts
For owners of highly appreciated property with charitable goals, a charitable remainder trust can sidestep the immediate capital gains hit while generating an income stream. You transfer the property into the trust and the trust sells it. Because the trust is exempt from income tax, the sale inside the trust triggers no immediate capital gains tax. The full proceeds are reinvested, you receive annual distributions for a set period or for life, and the remainder passes to your designated charity.
You also receive a partial charitable income tax deduction in the year you fund the trust, based on the present value of the charity’s future interest. The capital gains are not permanently erased. As distributions flow to you, they carry out the trust’s realized gains, so you pay tax in smaller increments over time rather than in a single year. It’s a deferral and income-smoothing tool, not a full elimination.
These trusts are complex, irrevocable, and carry ongoing administrative costs. They make sense mostly for very large unrealized gains where the owner genuinely wants to benefit a charity.
Hold Until Death: The Step-Up in Basis
This one is less a strategy than an estate-planning reality. If you hold appreciated property until you die, your heirs receive it with a basis equal to its fair market value on the date of your death. Every dollar of gain that accrued during your lifetime vanishes for income tax purposes.11Internal Revenue Service. Gifts and Inheritances
The numbers can be dramatic. A property bought for $150,000 that’s worth $900,000 when the owner dies passes to the heir with a $900,000 basis. If the heir sells immediately for $900,000, the capital gains tax is zero. Decades of appreciation, completely untaxed. This is why many families with large unrealized gains in real estate choose to hold rather than sell late in life.
Gifting property during your lifetime usually works worse. The recipient takes your original basis (a “carryover basis”), so the tax bill you were trying to avoid simply transfers to them. If a parent gifts a property with a $150,000 basis to a child who later sells for $900,000, the child owes tax on $750,000 of gain. Had the parent held until death, that tax would have been zero.
The 2026 federal estate and gift tax exemption is $15 million per person under recently enacted legislation, with no scheduled sunset. Most families can pass property through inheritance without triggering estate tax either. For estates that exceed the exemption, the calculation is more nuanced.
The Depreciation Recapture Trap
If you’ve been deducting depreciation on a rental or investment property (and the IRS assumes you have, whether you claimed it or not), the portion of your gain equal to the depreciation you were allowed is taxed at up to 25% when you sell.12Internal Revenue Service. Property (Basis, Sale of Home, Etc.) 5 This “unrecaptured Section 1250 gain” catches many rental property sellers off guard.
Say you bought a rental building for $300,000 and claimed $100,000 in depreciation, reducing your adjusted basis to $200,000. You sell for $400,000. Your total gain is $200,000, but $100,000 of that is recaptured depreciation taxed at up to 25%, and only the remaining $100,000 is taxed at your regular long-term capital gains rate.13Internal Revenue Service. Publication 544 (2025), Sales and Other Dispositions of Assets
Not every strategy on this page addresses recapture. A Section 1031 exchange can defer it along with the rest of the gain. The step-up in basis at death eliminates it entirely. An installment sale cannot defer it, and the primary residence exclusion doesn’t apply to property being sold as a rental. If you’re selling something you’ve depreciated, run the recapture number early. It is often the most surprising line on the closing tax bill.