Selling a home can come with one of the most generous tax breaks in the U.S. tax code — but a recent Tax Court ruling is a sharp reminder that this isn’t true in every situation.

In Pesarik v. Commissioner, a real-estate manager sold two properties in 2020 for a combined $743,800 (1) — properties he’d originally paid $424,750 for, and on which he believed he owed no tax gains, according to a Wall Street Journal story.

Thanks to Jeff Bezos, you can now become a landlord for as little as $100 — and no, you don't have to deal with tenants or fix freezers. Here's how

Dave Ramsey warns nearly 50% of Americans are making 1 big Social Security mistake — here’s what it is and the simple steps to fix it ASAP

Turning 50 with $0 saved for retirement? Most people don’t realize they’re actually just entering their prime earning decade. Here are 6 ways to catch up fast

Tax Court Chief Judge Patrick Urda ruled otherwise: Jeffrey Pesarik owed taxes on $255,281 of unreported income, plus penalty and interest charges. He had failed to prove one home qualified as his principal residence, and also didn’t substantiate much of the claimed improvement basis of the other.

The case shows what can happen when sellers assume they qualify for tax breaks they haven’t actually earned or documented.

Many sellers “assume the IRS won’t ask questions,” CPA Eric Bronnenkant of Edelman Financial Engines told the Wall Street Journal (2).

The home-sale exclusion under Section 121 of the tax code lets qualifying sellers exclude up to $250,000 of profit from a home sale if filing single, or up to $500,000 for married couples filing jointly. It’s a significant break, but it comes with strict conditions (3).

According to the IRS, to qualify, you must have owned and lived in the home as your primary residence for at least two of the five years immediately before the sale. You can only claim it once every two years. If you own more than one home, the IRS specifies the exclusion applies only to your main residence — not a vacation home, rental, or investment property (4).

While Pesarik satisfied the ownership timeline on his Massachusetts home, the problem was proving it was actually his main home.

The judge noted he had no Massachusetts tax filings or in-state driver’s license, and his credit card bills went to a P.O. box in New Hampshire. The driver’s license he used for ID was from Arizona. Utility usage didn’t establish consistent Massachusetts residency. So, the court denied the exclusion, costing him a taxable gain of over $137,000 on that property alone (2).

Related: How to invest in real estate without being a landlord

This is where many sellers get tripped up. The IRS doesn’t simply look at the deed. IRS Publication 523 spells out a “facts and circumstances” test: The main home is generally where you spend the most time, but other factors count too — like your mailing address, driver’s license, voter registration, bank account address and memberships in local organizations.

If you split time between two properties, you need to be able to demonstrate — with real paper trails — which one is your primary residence with consistent records (5).

Read More: 5 essential money moves to make once you’ve saved $50,000

Read More: Young millionaires are ditching stocks. Why older Americans should take note

Even when the exclusion doesn’t apply, or when the gain exceeds the exclusion limit, sellers can reduce taxable gains by raising their adjusted cost basis.

The IRS explains that your adjusted basis starts with your purchase price and rises with qualifying capital improvements, like a new roof, added square footage, a finished basement or upgraded systems (6). Routine repairs and maintenance don’t count, only work that adds value, prolongs the home’s useful life or adapts it to a new use (7).

Pesarik tried to use this on his New Hampshire property, claiming roughly $82,000 in renovations on a home he’d bought for $30,000 and sold for $187,000. That would have substantially reduced his taxable gain. But the court rejected most of it. His records, including credit card statements from home improvement stores and a spreadsheet, weren’t sufficient to prove what work was done or whether it qualified (2).

The lesson: Every capital improvement should be documented with contracts, permits, invoices and receipts, organized in a dedicated file from day one of ownership.

Pesarik’s losses didn’t stop at back taxes.

The court imposed a 20% accuracy-related penalty on his underpayment for negligence and substantially understating his tax liability. He argued a medical condition limited his ability to comply, but the court found he failed to show it actually affected his tax obligations (2).

The home-sale exclusion is one of the most valuable breaks in the tax code. The Pesarik case shouldn’t dissuade you from claiming it if you qualify, but it serves as a reminder to do so correctly, with the records to prove it. Before you sell, be sure to:

Confirm you truly qualify Does the home you’re selling meet the two-out-of-five-year ownership and use test? Can you prove it? If you split time between properties, document your primary residence consistently, not just when a sale is on the horizon.

Know the limits The exclusion can only be used once every two years, and any gain above the $250,000 or $500,000 cap is taxable. For second homes, rentals and investment properties, the exclusion doesn’t apply (4).

Track every qualifying improvement Your adjusted basis rises with capital improvements, and a higher basis means a lower taxable gain (6). Keep dated receipts, contractor invoices and permit records for every project.

Don’t forget selling costs Commissions, legal fees and other transaction costs can also reduce your taxable gain — but only if you’ve documented them (5).

Robert Kiyosaki begs investors not to miss this ‘explosion’ — says this 1 asset will surge 400% in a year

Vanguard reveals what could be coming for U.S. stocks, and it’s raising alarm bells for retirees. Here’s why and how to protect yourself

This 20-year-old lotto winner refused $1M in cash and chose $1,000/week for life. Now she’s getting slammed for it. Which option would you pick?

Taxes are going to change for retirees under Trump’s ‘big beautiful bill’ — here are 4 reasons you can’t afford to waste time

Join 250,000+ readers and get Moneywise’s best stories and exclusive interviews first — clear insights curated and delivered weekly. Subscribe now.

We rely only on vetted sources and credible third-party reporting. For details, see our editorial ethics and guidelines.

Tax Notes (1); The Wall Street Journal (2); IRS (3,4,5,6,7)

This article provides information only and should not be construed as advice. It is provided without warranty of any kind.