In many years, investors worry more about keeping their taxable gains down. This year, though, most shareholders have a much different concern: trying to make the most of big losses.

The steep decline in stocks has wreaked havoc on many portfolios. But the tax code affords some relief to suffering investors. If you decide to sell your losing shares, the resulting tax losses can save you some money in taxes -- sometimes quite a bit.

To make the most of tax losses, however, you have to know the rules. Here's a list of things to keep in mind.

Step 1: Pick the shares to sell.
If you bought all your shares in a company at the same time -- or you sell them all at once -- then this rule doesn't matter. But if you have multiple purchases and decide to sell only part of your position, then it can make a big difference which shares you sell.

For stocks from the same company, the default Internal Revenue Service rule is first in, first out -- you're deemed to sell whichever shares you bought earliest. But often, you paid the least for those early shares, so often, you'll have a gain or a small loss on your first shares, but a big loss on later shares.

Sometimes, if you bought shares at different times, you can save a bundle by selling certain shares first -- even if they weren't the first ones you bought. Say, for instance, you bought 1,000 shares of a stock back in 2003, and then bought another 1,000 shares last year. You want to sell 1,000 shares now. You might have a gain on your 2003 shares but a loss on your 2007 shares, so obviously you'll want to sell the more recent shares to lock in a tax benefit. Here are some examples:

Stock

Gain on 2003 Shares

Loss on 2007 Shares

Taxes Saved

Apache (NYSE:APA)

$41,640

($19,840)

$9,222

Transocean (NYSE:RIG)

$55,810

($43,290)

$14,865

Intuitive Surgical (NASDAQ:ISRG)

$154,680

($97,090)

$37,766

GameStop (NYSE:GME)

$14,770

($28,590)

$6,504

Titanium Metals (NYSE:TIE)

$7,300

($17,930)

$3,785

Loews (NYSE:L)

$14,840

($15,510)

$4,553

Nasdaq OMX Group (NASDAQ:NDAQ)

$17,110

($14,310)

$4,713

Source: Yahoo! Finance. Tax savings assumes that the 15% rate applies to capital gains and losses.

The key is that you have to identify which shares you want to sell at the time of the sale, and you need to get written confirmation from your broker. That's particularly difficult with some online brokers, so make sure you know how to do it right; some trading interfaces mean you have to go to some effort to speak to an actual person.

Step 2: Know your limits.
The IRS will happily let you take as many gains as you want. But when it comes to losses, you can definitely have too much of a bad thing.

Here's the scoop on limits on losses:

  • If you have gains from selling investments this year, you can use losses to completely wipe out those gains.
  • Beyond that, you can use up to $3,000 per year in losses against other types of income, including wages, interest, and dividends.
  • You can carry forward any additional losses for use in future years.

What this means is that if you already have enough losses to cover your gains plus $3,000, there's no hurry to sell the rest of your losers for tax purposes. On the other hand, if you already have those losses, don't worry -- you can always use them later.

Step 3: Don't get washed.
Often, you'll want to sell a stock to take a tax loss, but you'll also want to keep owning it in the hope that it'll rebound. The so-called wash sale rules impose some restrictions on that.

If you sell a stock to take a loss, you can't buy it back for 30 days. Moreover, you can't sell a stock in one account and buy it back in another account -- even if it's a retirement account. The rules also work backward; that is, if you buy extra shares of a stock, you can't sell and take a loss for 30 days.

As with many tax rules, these can get complicated, so if you have questions, talk to your accountant. But being smart with your selling can at least make you feel a little better about the losses you've suffered this year.

For more on making the most of a tough market, read about: