Wash Sale: The Tax Loss Rule That Can Quietly Erase Your Deduction
Selling a losing investment to claim a tax deduction sounds simple, until a repurchase a few weeks later makes the deduction disappear entirely. The wash sale rule exists specifically to stop investors from harvesting a tax loss while never really leaving the position, and its reach across accounts catches far more people than its simple premise suggests.
The core principle
A wash sale occurs when an investor sells a security at a loss and then buys the same security, or one the IRS considers "substantially identical," within 30 days before or after the sale date. Counting both sides of the sale, this creates a 61-day window in total: 30 days before, the sale date itself, and 30 days after. Any purchase that falls inside that window disallows the loss for current-year tax purposes, regardless of how small the repurchase or how unrelated the investor's stated intent was.
The disallowed loss is not simply erased; it is deferred, though the deferral mechanism catches many investors off guard. The disallowed amount is added to the cost basis of the replacement shares, so the loss effectively rejoins your numbers the next time you sell those replacement shares for good, provided that later sale is not itself another wash sale. This deferral only works cleanly, however, when the replacement shares are held in the same type of account as the original sale; when a replacement purchase happens inside a tax-advantaged account like an IRA, the basis adjustment mechanism breaks down entirely, because IRA basis is not tracked and adjusted the way taxable account basis is, and the loss is lost for good rather than merely deferred.
"Substantially identical" is deliberately broader than "identical." Selling one S&P 500 index fund and immediately buying a different S&P 500 index fund from another provider is widely treated as substantially identical because both funds track the same index and hold effectively the same underlying securities. Selling an S&P 500 fund and buying a total US stock market fund sits in a genuine gray area that many tax professionals treat as distinct enough to avoid the rule, though the IRS has never published a precise, mechanical test for the phrase.
Options and other derivatives on the same underlying security are swept into the rule as well: selling a stock at a loss and simultaneously buying a call option on that same stock, or selling a put that would effectively reacquire the position, can trigger a wash sale just as directly as buying the shares outright, since the economic exposure being reestablished is functionally the same. This surprises a meaningful share of options-using investors, who sometimes assume the rule applies only to literal share-for-share repurchases rather than to any position that recreates substantially the same market exposure.
How the math works
Example 1: a standard wash sale and its basis adjustment. An investor buys 100 shares of a fund at $50 per share, a $5,000 cost basis. The fund drops to $40, and the investor sells all 100 shares for $4,000, realizing a $5,000 − $4,000 = $1,000 loss. Fourteen days later, still within the 30-day window, the investor buys the same fund back at $42, a total cost of $4,200. The wash sale rule disallows the full $1,000 loss for this year's taxes. Instead, that $1,000 is added to the cost basis of the new shares: $4,200 + $1,000 = $5,200 total basis, or $52 per share, even though the investor only paid $42 per share in cash. The loss is not gone, it is baked into a higher basis that will produce a larger future loss, or smaller future gain, whenever these replacement shares are eventually sold outside any further wash sale window.
Example 2: the version where the loss is permanently lost. Suppose the same investor sells 100 shares at a $1,000 loss in a taxable brokerage account, but instead of repurchasing in the same taxable account, buys the identical fund inside an IRA twelve days later. The wash sale rule still disallows the $1,000 loss, but because IRA shares do not carry a trackable, adjustable cost basis for this purpose the way taxable shares do, there is no mechanism to add the $1,000 back onto the IRA shares' basis. The full $1,000 loss is permanently forfeited rather than deferred, a materially worse outcome than the first example, and one the investor would have avoided entirely simply by waiting 31 days or repurchasing in the original taxable account instead.
How it shows up in real portfolios
Tax-loss harvesting, deliberately selling a losing position to realize a deductible loss while replacing it with a similar, non-identical holding to stay invested, is where investors most often encounter this rule in practice. A common, generally accepted approach is swapping one broad total market index fund for a different provider's broad total market index fund, or swapping a large-cap growth fund for a large-cap fund from a different provider with a somewhat different construction methodology, staying invested in roughly the same market exposure while avoiding the substantially-identical trap.
A high-earning professional running automated tax-loss harvesting across several accounts, a taxable brokerage account, a spouse's 401(k), and an IRA, is exposed to a subtler version of the problem: the rule applies across every account either spouse controls, including retirement accounts, so an automatic dividend reinvestment inside a completely separate IRA can unknowingly trigger a wash sale on a harvest executed in the taxable account. This cross-account reach is the single most common way sophisticated investors trip the rule without intending to, since most people mentally track their taxable brokerage account closely but pay far less attention to automatic reinvestment settings inside a 401(k) or IRA holding a similar fund.
Actionable breakdown
- Before harvesting a loss, check:
- Every account you and your spouse control for the same holding.
- Whether dividend reinvestment is set to automatic anywhere.
- Whether the replacement fund is genuinely distinct, not substantially identical.
- Whether any pending purchase order falls inside the 61-day window.
- Watch for these red flags:
- Repurchasing the identical security within 30 days in any account.
- Buying the replacement inside an IRA rather than the original taxable account.
- Swapping into a fund that tracks the exact same index from a different provider.
- Turning off automatic reinvestment only in the account where you sold, not everywhere else.
- Wait at least 31 days before repurchasing an identical security.
- Or swap into a genuinely different, non-identical fund to stay invested.
- Repurchase replacement shares in the same taxable account, never an IRA.
- Use your broker's wash sale flags to check before filing taxes.
The rule's 30-day window is calculated in calendar days, not trading days, and it applies regardless of the size of the repurchase; buying back even a single share of a substantially identical security within the window is enough to trigger a proportional wash sale determination on the corresponding portion of the loss, a detail that catches investors who assume a small, partial repurchase falls below some unstated threshold that does not actually exist in the rule.
Common pitfalls
- Selling a security in a taxable account, then buying it back inside an IRA, which disallows the loss and permanently loses the basis adjustment because IRA basis is not tracked the same way.
- Assuming the rule only applies within a single brokerage account, when it applies across every account an investor or their spouse controls, including retirement accounts.
- Reinvesting dividends automatically into the same fund just sold at a loss, unintentionally triggering the rule without an active repurchase decision.
- Swapping into a "different" fund that tracks the identical index, which many tax professionals and the IRS itself would treat as substantially identical rather than a genuine change in exposure.
Related concepts
For the loss being disallowed in the first place, see capital loss and cost basis. For how the disallowed amount interacts with your original purchase records, see average cost basis. For the broader tax strategy this rule most directly constrains, see the guide on tax efficiency.
The bottom line
A harvested tax loss only counts if you stay out of the same or a substantially identical security for the full 30 days on both sides of the sale, in every account you and your spouse own.