US Tax Tools
Investment

Wash Sale Rule: What Investors Need to Know Before Tax-Loss Harvesting

Tax-loss harvesting — selling losing investments to offset gains — is one of the best tools for reducing your tax bill. But the IRS built a guardrail: the wash sale rule. Repurchase a “substantially identical” security too quickly after selling at a loss, and the IRS disallows the loss entirely. Certain mistakes can even make the loss permanently unrecoverable.

What Triggers a Wash Sale?

A wash sale occurs when you:

  1. Sell a security at a loss, AND
  2. Buy a substantially identical security within 30 days before or 30 days after the sale

This creates a 61-day window centered on the sale date. Buy the same or a substantially identical security anywhere in that window, and the loss is disallowed.

The 61-Day Window Visualized

Suppose you sell shares of XYZ Corp at a loss on June 15:

PeriodDatesWhat Triggers a Wash Sale
30 days before saleMay 16 – June 14Buying XYZ in this window
Sale dateJune 15You sell XYZ at a loss
30 days after saleJune 16 – July 15Buying XYZ in this window

If you purchased XYZ on May 20 (before the sale) or on July 1 (after the sale), you have a wash sale. The loss is disallowed.

Important: The 30-day windows use calendar days, not trading days. Weekends and holidays count.

What Happens to the Disallowed Loss?

The disallowed loss is not gone forever (in most cases). It gets added to the cost basis of the replacement shares. This means you will eventually recover the loss when you sell the replacement shares — assuming you do not trigger another wash sale.

Worked Example

  1. January 10: You buy 100 shares of ACME at $50/share ($5,000 total cost)
  2. March 5: ACME drops. You sell all 100 shares at $30/share ($3,000 proceeds). Your loss is $2,000.
  3. March 20: ACME looks cheap. You buy 100 shares at $32/share ($3,200 total cost). This is only 15 days after the sale — wash sale triggered.

Result:

  • Your $2,000 loss is disallowed — you cannot deduct it on your 2026 return.
  • The disallowed loss is added to your new shares’ cost basis: $32 + $20 = $52 per share (adjusted basis).
  • Your holding period from the original purchase (January 10) also transfers to the new shares.

If you later sell these replacement shares at $60, your taxable gain is $60 - $52 = $8 per share instead of $60 - $32 = $28. You eventually recover the $2,000 — but only when you sell without triggering another wash sale.

It Applies Across ALL Your Accounts

This is where many investors get caught off guard. The wash sale rule applies across your entire portfolio, not just one account. The IRS considers purchases in:

  • Your other brokerage accounts
  • Your spouse’s accounts (for joint filers)
  • Your IRA (Traditional or Roth)
  • Your 401(k) or other retirement accounts
  • Accounts where you set up automatic dividend reinvestment (DRIP)

Example: You sell a losing position in your Fidelity taxable account on March 1. On March 10, your Vanguard 401(k) automatically buys shares of the same fund through your regular contribution. That is a wash sale. Similarly, automatic dividend reinvestment (DRIP) within 30 days of your sale can trigger a partial wash sale — turn off DRIP before harvesting losses.

What Is “Substantially Identical”?

The IRS has never provided a precise definition, which creates a gray area. Here is the general consensus:

Clearly Substantially Identical (Triggers Wash Sale)

  • Same stock (sell and rebuy Apple shares)
  • Same mutual fund or ETF (sell and rebuy Vanguard Total Stock Market — VTSAX)
  • Different share classes of the same fund (sell VTSAX, buy VTI of the same index)

Generally NOT Substantially Identical (Safe to Swap)

  • Different index funds tracking different indices (sell S&P 500 fund, buy Total Stock Market fund)
  • Stock of one company vs. stock of a different company in the same sector (sell Ford, buy GM)
  • A stock vs. an ETF that holds that stock among many others (sell Apple, buy QQQ — though this is not 100% settled)

When in doubt, swap to a fund that tracks a genuinely different index or benchmark. Two ETFs tracking the same index from different providers are widely considered substantially identical.

The IRA Wash Sale Trap: Permanent Loss

This is the most dangerous pitfall of the wash sale rule. If you sell a security at a loss in a taxable account and buy a substantially identical security within 30 days in your IRA, the loss is disallowed — and because the replacement shares are in a tax-advantaged account, you can never recover the loss.

The disallowed loss would normally be added to the cost basis of the replacement shares. But cost basis in an IRA is irrelevant — withdrawals from a Traditional IRA are taxed as ordinary income regardless of basis, and Roth withdrawals are tax-free. The $2,000 loss from our earlier example would simply vanish.

This applies to 401(k) accounts as well. Never buy the same security in a retirement account within 30 days of harvesting a loss in a taxable account.

Strategies to Avoid Wash Sales

1. Wait 31 Days

The simplest approach: sell the losing position and wait 31 full days before repurchasing. The risk is that the security rebounds during the waiting period and you miss the recovery.

2. Buy a Similar (Not Identical) Fund Immediately

Sell your S&P 500 index fund and immediately buy a Total Stock Market fund, a large-cap value fund, or another fund that provides similar but not identical market exposure. After 31 days, you can switch back to your original fund if you prefer.

3. Harvest in Taxable Accounts Only

Avoid the permanent loss trap by only tax-loss harvesting in taxable brokerage accounts. Pause any automatic purchases of the same securities in retirement accounts during the 61-day window.

No Wash Sale Rule for Gains

An important distinction: the wash sale rule only applies to losses. If you sell a stock at a gain and immediately rebuy it, there is no wash sale issue. You pay tax on the gain and get a fresh, higher cost basis.

This matters for estate planning and portfolio rebalancing — you can freely sell appreciated positions and repurchase without any wash sale concern.

Key Takeaways

  • The wash sale rule disallows a loss if you buy a substantially identical security within 30 days before or after the sale (a 61-day window).
  • Disallowed losses are added to the replacement shares’ cost basis — you recover them later, unless the replacement is in an IRA or 401(k), where the loss is permanently destroyed.
  • The rule applies across all your accounts, including your spouse’s accounts and retirement plans.
  • Swap to a similar but not identical fund to maintain market exposure while legally harvesting the loss.
  • Watch for automatic dividend reinvestment, 401(k) auto-contributions, and other automated purchases that can accidentally trigger wash sales.
  • The wash sale rule does not apply to gains — only losses.

Check our Wash Sale Calculator to see how a wash sale affects your cost basis, or explore tax-loss harvesting opportunities with the Tax-Loss Harvesting Calculator.

wash-sale tax-loss-harvesting investing capital-gains

Last updated April 12, 2026 Tax year 2025-26

Data sources: IRS (irs.gov), Social Security Administration

This tool is general information only, not financial advice.

Reviewed by USTax Tools Editorial Desk

Read our methodology →