You can legally avoid or reduce capital gains tax when selling property through a handful of well-defined tools, and which one fits depends on what you’re selling. Homeowners rely on the Section 121 exclusion, which shelters up to $250,000 of gain for single filers and $500,000 for married couples filing jointly. Investment property sellers use like-kind exchanges, installment sales, opportunity zone reinvestments, and loss harvesting. Heirs get a stepped-up basis that can erase decades of appreciation. The rest is knowing which rules apply, and where the traps sit.
Exclude Up to $500,000 on Your Primary Home
The single most powerful tool for a home sale is the Section 121 exclusion. If you owned and lived in the home as your primary residence for at least two of the five years before the sale, you can exclude up to $250,000 of gain from your income. Married couples filing jointly can exclude up to $500,000, as long as at least one spouse meets the ownership requirement and both meet the use requirement.1Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain from Sale of Principal Residence
The two years of residence don’t need to be consecutive. You could live in the home for 14 months, move away temporarily, return for 10 months, and still qualify as long as your total time there adds up to at least 24 months within that five-year window.2Internal Revenue Service. Topic No 701, Sale of Your Home Profit above the exclusion limit gets taxed at long-term capital gains rates.
One detail trips people up: if you converted a rental or investment property into your primary residence, the gain attributable to periods of “nonqualified use” (time the property was not your primary residence) does not qualify for the exclusion. The IRS allocates your total gain based on the ratio of nonqualified-use time to total ownership time. Nonqualified use before January 1, 2009 doesn’t count against you, and any period after your last day of primary-residence use is also excluded from the penalty. Someone who rented a property for eight years and then lived in it for two still can’t shelter the full gain.
Partial Exclusion for Early Sales
If you sell before hitting the two-year mark because of a job relocation, a health condition, or an unforeseen event like a natural disaster, you can claim a partial exclusion. Divide the time you actually met the ownership or use requirement by two years, then multiply by the full exclusion amount. Someone who lived in a home for 15 months before relocating for work would get 15/24 of the $250,000 exclusion, or roughly $156,250.3Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain from Sale of Principal Residence – Section C
Extended Timeline for Military Service Members
Active-duty military personnel, Foreign Service members, and intelligence community employees can suspend the five-year look-back period for up to 10 years while on qualified official extended duty. That stretches the window to 15 years. To qualify, the service member must be stationed at least 50 miles from the property or living in government quarters under orders, and the duty period must exceed 90 days. The election applies to only one property at a time.4Office of the Law Revision Counsel. 26 US Code 121 – Exclusion of Gain from Sale of Principal Residence – Section D9
Cut the Taxable Gain with Basis Adjustments and Selling Costs
Your taxable gain isn’t just the sale price minus what you paid. The IRS lets you increase your cost basis by adding permanent improvements made during ownership: a new roof, a kitchen remodel, a finished basement, an added bathroom. These are capital improvements that add value or extend the property’s life, not routine maintenance like repainting or fixing a leaky faucet.5Internal Revenue Service. Topic No 703, Basis of Assets
If you bought a home for $300,000 and put $50,000 into a kitchen renovation, your adjusted basis is $350,000. When you sell for $600,000, your gain is $250,000 rather than $300,000. That $50,000 reduction could be the difference between owing tax and falling entirely within the Section 121 exclusion.
Selling expenses also reduce your gain. The IRS allows you to subtract real estate agent commissions, advertising fees, legal fees, and loan charges you paid on the buyer’s behalf.6Internal Revenue Service. Publication 523, Selling Your Home On the purchase side, you can add settlement fees like title insurance, recording fees, survey costs, and transfer taxes to your original basis. Keep every receipt and closing statement. These records are your only proof during an audit, and they can shave tens of thousands off a taxable gain.
Defer the Tax with a 1031 Like-Kind Exchange
If you’re selling rental or business property rather than a personal home, a Section 1031 like-kind exchange lets you defer the entire capital gains tax by rolling the proceeds into another investment property. The replacement property must also be held for business or investment use, but the definition of “like-kind” is broad: you can trade an apartment building for vacant land, or a warehouse for a retail property.7Office of the Law Revision Counsel. 26 US Code 1031 – Exchange of Real Property Held for Productive Use or Investment
The process runs on two non-negotiable deadlines. From the day you transfer the relinquished property, you have 45 calendar days to identify potential replacement properties in writing. You then must close on the replacement property within the earlier of 180 calendar days or the due date (with extensions) of your tax return for the year the exchange began.8Internal Revenue Service. Like-Kind Exchanges – Real Estate Tax Tips Miss either deadline and the entire gain becomes taxable immediately.
A qualified intermediary must hold the sale proceeds throughout the exchange. If you touch the money at any point, even briefly, the IRS treats it as a completed sale and the deferral fails. Full deferral also requires that the replacement property’s value equals or exceeds the relinquished property’s value. If you trade down in value or pocket some cash (called “boot”), you’ll owe tax on the difference.7Office of the Law Revision Counsel. 26 US Code 1031 – Exchange of Real Property Held for Productive Use or Investment
“Deferral” matters here. A 1031 exchange doesn’t eliminate the tax; it pushes it forward. Your replacement property inherits the original property’s basis, so the deferred gain stays embedded until you eventually sell without exchanging again. Investors who chain 1031 exchanges throughout their careers sometimes hold until death, at which point the step-up in basis eliminates the deferred gain entirely.
Watch Out for Depreciation Recapture
This is where rental property sellers get surprised. Even if you defer your capital gain through a 1031 exchange or offset it with losses, depreciation recapture operates as a separate tax layer. Every year you own a rental property, you’re expected to claim depreciation deductions that reduce your cost basis. When you sell, the IRS taxes all that accumulated depreciation at a maximum federal rate of 25%, regardless of your income bracket.9Internal Revenue Service. Treasury Decision 8836 – Unrecaptured Section 1250 Gain
The IRS calculates recapture based on depreciation “allowed or allowable,” which means you owe the tax on the full depreciation amount even if you never actually claimed the deduction. Skipping depreciation on your tax returns doesn’t protect you. Personal property inside the rental, like appliances or carpeting, faces even steeper recapture at ordinary income rates up to 37%.
A 1031 exchange defers depreciation recapture along with the capital gain. But if you eventually sell outright, the entire accumulated depreciation from every exchanged property in the chain comes due at once.
Spread the Tax Through an Installment Sale
An installment sale lets you spread the tax hit over multiple years instead of paying it all at once. Any sale where you receive at least one payment after the tax year of the sale qualifies. Instead of reporting the full gain up front, you report a proportional share of the gain with each payment you receive, based on the gross profit ratio of the transaction.10Internal Revenue Service. Publication 537, Installment Sales
Each payment you collect includes three components: a return of your original basis, a portion of the gain, and interest income. The buyer typically secures future payments with a promissory note or deed of trust. This method doesn’t eliminate the tax, but it can keep you in a lower bracket during the payout period, reducing the effective rate you pay on each slice of gain.11Office of the Law Revision Counsel. 26 US Code 453 – Installment Method
Two limitations to know. If you regularly sell properties as a dealer (someone who holds real estate primarily for sale to customers in the ordinary course of business), you generally cannot use the installment method.11Office of the Law Revision Counsel. 26 US Code 453 – Installment Method And if the sale price exceeds $150,000 and your total outstanding installment obligations exceed $5 million at year-end, you’ll owe interest to the IRS on the deferred tax liability for each year the balance stays above that threshold. The interest rate follows the IRS underpayment rate, so for large transactions the carrying cost of deferral can be significant.
Reinvest in a Qualified Opportunity Zone
If you’ve already sold property and realized a gain, reinvesting that gain into a Qualified Opportunity Fund within 180 days defers the tax on the original gain. The fund must invest in designated low-income census tracts called Opportunity Zones.12Office of the Law Revision Counsel. 26 USC 1400Z-2 – Special Rules for Capital Gains Invested in Opportunity Zones
Timing is critical for 2026. Under the original program, all deferred gains must be recognized by December 31, 2026, regardless of whether you’ve sold the Opportunity Zone investment. The basis step-up benefits that once rewarded 5-year and 7-year holding periods are effectively unavailable for new investments because the deferral window closes too soon.12Office of the Law Revision Counsel. 26 USC 1400Z-2 – Special Rules for Capital Gains Invested in Opportunity Zones
The most valuable benefit remains intact for existing investors who can hold for 10 years: any appreciation on the Opportunity Zone investment itself becomes permanently tax-free. You elect to reset the investment’s basis to its fair market value at sale, wiping out all post-investment appreciation. A newer version of the program has introduced enhanced benefits for investments in rural Qualified Opportunity Funds, including a 30% basis step-up, though eligibility rules differ from the original program.13U.S. Department of Housing and Urban Development. Opportunity Zones Investors
Offset the Gain with Capital Losses
Investment losses from stocks, bonds, or other property can offset a real estate gain. The IRS requires you to net long-term losses against long-term gains first, and short-term losses against short-term gains. Any excess losses from one category then offset gains in the other.14Internal Revenue Service. Topic No 409, Capital Gains and Losses
If your total losses for the year exceed your total gains, you can deduct up to $3,000 of the remaining loss against ordinary income ($1,500 if married filing separately). Anything beyond that carries forward to future tax years indefinitely.14Internal Revenue Service. Topic No 409, Capital Gains and Losses
Timing matters. Selling underperforming investments in the same year you sell a high-value property can reduce your net taxable gain substantially. This is sometimes called tax-loss harvesting, and it works for both homeowners who exceed the Section 121 exclusion and investment property sellers who can’t use a 1031 exchange.
Inherit Property and Take the Stepped-Up Basis
Inheriting property is one of the most tax-efficient ways to receive real estate. Under federal law, the cost basis of inherited property resets to its fair market value on the date of the prior owner’s death.15Office of the Law Revision Counsel. 26 USC 1014 – Basis of Property Acquired from a Decedent All the appreciation that occurred during the decedent’s lifetime disappears from the tax rolls.
If a parent bought a house for $100,000 forty years ago and it’s worth $600,000 at death, the heir’s basis is $600,000. Selling it shortly after for $620,000 produces only a $20,000 taxable gain instead of $520,000. This is why many investors who’ve built large deferred gains through 1031 exchanges plan to hold until death rather than ever selling outright.
The step-up applies to property included in the decedent’s estate, including assets held in certain trusts. For 2026, the federal estate tax filing threshold is $15,000,000 per person, meaning most estates won’t owe estate tax either.16Internal Revenue Service. Estate Tax
Donate Appreciated Property to Charity
Donating appreciated real estate directly to a qualified charity lets you sidestep capital gains tax entirely while claiming a charitable deduction for the property’s fair market value. The key is that you donate the property itself rather than selling it first and giving the cash. If you sell first, you owe capital gains tax on the proceeds regardless of what you do with the money afterward.
To qualify for the full fair-market-value deduction, you must have held the property for more than one year. Donations of appreciated real estate worth more than $5,000 require a qualified appraisal. The deduction for donated appreciated property is limited to 30% of your adjusted gross income in the year of the gift, but any unused portion carries forward for up to five additional tax years. The property must also be free of debt; mortgaged property triggers “bargain sale” rules that generate partial capital gains tax and reduce your deduction.
This strategy works best for property owners sitting on large unrealized gains who have charitable intent and enough other income to benefit from the deduction. Donor-advised funds and charitable remainder trusts are common vehicles for real estate donations, though the mechanics of transferring a deed to a charity are more involved than donating stock.
One More Bracket Worth Checking
Before assuming you’ll owe anything, look at where your taxable income actually falls. For 2026, long-term capital gains are taxed at 0% for taxable income up to $49,450 (single) or $98,900 (married filing jointly).17Tax Foundation. 2026 Tax Brackets and Federal Income Tax Rates A retiree with modest income who sells a rental at a moderate profit might owe nothing on the gain at all. Property held for a year or less, though, gets taxed at ordinary income rates up to 37%, so holding for more than 12 months before selling is often the simplest planning move of all.
Higher earners face the opposite problem: an additional 3.8% net investment income tax on top of the capital gains rate when modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly).18Office of the Law Revision Counsel. 26 USC 1411 – Tax on Net Investment Income Gain excluded under the Section 121 primary residence exclusion doesn’t count toward this surcharge, which is one more reason the exclusion is worth structuring around when you can.