Back to Learn

The Wash Sale Rule Explained

Last updated: July 2026

What is a wash sale?

A wash sale happens when you sell a security at a loss and then buy the same or a "substantially identical" security within a specific window of time. When the IRS flags a sale as a wash sale, the tax loss you were hoping to claim gets disallowed. You can't use it to offset gains or reduce your income that year.

The rule exists to prevent a simple loophole: selling a stock just to claim the loss, then immediately buying it back so your portfolio never actually changes. The IRS considers that a wash, not a real change in your investment position.

The wash sale rule is codified in Section 1091 of the Internal Revenue Code. It applies to stocks, bonds, mutual funds, ETFs, and options.

The 30-day window

The wash sale window covers 30 calendar days before and 30 calendar days after the sale. Including the sale date itself, that's a total of 61 days. If you buy the same or substantially identical security anywhere inside that window, the loss is disallowed.

Most people think about the 30 days after the sale: "I sold it, so I need to wait 30 days before buying it back." That part is intuitive. But the rule also looks backwards. If you bought shares of the same security within the 30 days before your sale, that purchase also triggers a wash sale.

This backward-looking window catches scenarios like dollar-cost averaging into a position and then selling older shares at a loss. If your recent purchase falls within the window, the loss on those older shares is disallowed.

What triggers a wash sale

A wash sale is triggered when all three of these conditions are met:

  1. You sell a security at a loss
  2. Within 30 days before or after that sale, you buy the same or a substantially identical security
  3. The replacement purchase is in any account you own (taxable brokerage, IRA, Roth IRA, 401(k), or even your spouse's accounts)

That third point surprises many people. The wash sale rule applies across all of your accounts. Selling VTI at a loss in your taxable account while your 401(k) auto-purchases VTI on the same day will trigger a wash sale.

Dividend reinvestment (DRIP) can also trigger wash sales. If a fund automatically reinvests dividends into new shares, that reinvestment counts as a purchase. Selling shares of that fund at a loss within 30 days of a dividend reinvestment triggers a wash sale on the portion covered by the reinvested shares.

Examples

Example 1: Classic wash sale

You bought 100 shares of VTI at $200 per share. The price drops to $180, and you sell all 100 shares on June 15, realizing a $2,000 loss. On July 1 (16 days later), you buy 100 shares of VTI back at $182. Because you repurchased within 30 days, the $2,000 loss is disallowed.

Example 2: The backward window

On March 1, you buy 50 shares of AAPL. On March 20 (19 days later), you sell 50 older shares of AAPL at a $1,500 loss. Even though you sold after the purchase, the March 1 buy falls within the 30-day window before the sale. Wash sale triggered.

Example 3: Cross-account wash sale

You sell 200 shares of VOO at a $3,000 loss in your taxable brokerage on October 10. On October 15, your Roth IRA automatically buys VOO as part of its regular contribution investment. The loss is disallowed because the replacement purchase happened in another account you own within 30 days.

Example 4: Not a wash sale

You sell 100 shares of VTI (which tracks the CRSP US Total Market Index) at a $2,000 loss. The same day, you buy 100 shares of ITOT (which tracks the S&P Total Market Index). These ETFs cover similar market segments but track different indexes. Under the conservative same-index interpretation, this is not a wash sale. You keep the $2,000 loss and maintain similar market exposure. For a real-world example of this kind of harvest, see our walkthrough of harvesting a $374 loss on SPY.

How wash sales affect your cost basis

When a wash sale is triggered, the disallowed loss isn't gone forever (usually). It gets added to the cost basis of the replacement shares. This means you'll eventually recover the loss when you sell the replacement shares, assuming you don't trigger another wash sale at that point.

Using the numbers from Example 1 above: you sold VTI at a $2,000 loss, then bought it back at $182 per share. The $2,000 disallowed loss gets added to your new cost basis. Instead of a cost basis of $182 per share ($18,200 total), your adjusted cost basis becomes $202 per share ($20,200 total). When you eventually sell those shares, your gain will be $2,000 lower (or your loss $2,000 larger) than it would have been without the adjustment.

The tax benefit isn't eliminated, just deferred. But deferral has a real cost: you lose the ability to use that loss this tax year, and the time value of that tax savings is gone.

The IRA trap: permanent loss disallowance

There is one scenario where a wash sale loss is gone for good. If the replacement purchase happens in a tax-advantaged account like an IRA, Roth IRA, or 401(k), the disallowed loss cannot be added to the replacement shares' cost basis. The IRS does not allow cost basis adjustments inside tax-advantaged accounts. The loss simply disappears.

This was clarified in Revenue Ruling 2008-5. It's one of the most expensive mistakes an investor can make, because unlike a normal wash sale, there's no way to recover the loss later.

Watch out for automatic purchases

If your IRA or 401(k) automatically invests contributions or reinvests dividends into funds you also hold in a taxable account, those automatic purchases can trigger a permanent wash sale. Check your automatic investment schedules before harvesting losses.

What counts as "substantially identical"?

The IRS has never formally defined "substantially identical" for ETFs or mutual funds. The phrase appears in the wash sale statute, but there's no regulation or ruling that tells you exactly which funds count.

The most common conservative approach, used by tax professionals and sites like Bogleheads, is the "same index" test: two ETFs that track the exact same underlying index are considered substantially identical. For example, SPY and VOO both track the S&P 500 index, so selling one and buying the other within 30 days would trigger a wash sale under this interpretation.

Two ETFs that cover a similar market segment but track different indexes are generally considered safe. VTI (CRSP US Total Market Index) and ITOT (S&P Total Market Index) both give you broad US stock exposure, but because they track different indexes with different construction rules, they're not substantially identical.

You can find common same-index groups and valid replacement pairs in our TLH Replacement Securities Reference.

How to avoid wash sales when tax loss harvesting

Tax loss harvesting and wash sales are closely connected. The whole point of TLH is to realize losses you can use on your tax return. But if you trigger a wash sale in the process, you lose that benefit (temporarily or permanently). Here are the practical steps to harvest losses cleanly:

  1. Use a replacement security from a different index. When you sell a position at a loss, buy a similar fund that tracks a different index. This keeps your portfolio allocated the way you want while avoiding the substantially identical problem.
  2. Check all your accounts. Before selling, look at your IRA, Roth IRA, 401(k), and spouse's accounts for recent or upcoming purchases of the same security. Automatic contributions and DRIP are easy to overlook.
  3. Turn off DRIP temporarily. If you're planning to harvest a loss on a fund that reinvests dividends, consider turning off automatic reinvestment for that fund during the 61-day wash sale window.
  4. Wait 31 days before buying back. If you want to return to the original security instead of staying in the replacement, wait at least 31 days after the sale before repurchasing.
  5. Automate the monitoring. Tracking wash sale windows across multiple accounts and securities manually is tedious and error-prone. Harvest IY scans your connected accounts for tax loss harvesting opportunities and checks for wash sale conflicts automatically.

This content is for informational purposes only and should not be taken as investment advice or tax advice. Consult a qualified tax professional for advice specific to your situation.