With the re-election of President Bush, the tax breaks on capital gains are safe for the foreseeable future.

That means the annual year-end ritual of tax-loss "harvesting," or selling off selected losses in an investment portfolio and using the losses to offset gains, can proceed as usual.

Had John Kerry, with his pledge to reduce taxes on higher income taxpayers, been the victor instead, investors owning stocks and mutual funds with large embedded capital gains might have been scared into wholesale selling this year while the tax breaks were still good.

"We can probably assume the capital gains rates will stay the same," says Bob Scharin, editor of RIA's

Practical Tax Strategies

, a journal for tax professionals. "Bush wants to make his tax cuts permanent."

In 2003, Bush promoted the tax bill that reduced the tax on long-term capital gains, those held for more than one year, from 20% to 15% for those in the higher tax brackets and from 10% to 5% for those in the lower brackets. In 2008, the 5% rate drops to 0%, and in 2009, all capital gains rates revert to their pre-2003 levels unless new legislation is passed.

Despite warnings that the country cannot afford additional tax cuts because of the huge federal deficit, Bush has vowed to make his tax reductions on capital gains, dividends and other income permanent. That, no doubt, contributed to the market's postelection rally.

Rally or not, many investors usually hold a stock or mutual fund in their portfolio that is faring poorly.

The tax code provides a consolation prize of sorts to investors who own stocks like

Intel

(INTC) - Get Report

, down 30% over the past year as part of a semiconductor slump, or

Marsh & McLennan

(MMC) - Get Report

, whose shares recently plummeted from $45 to $23 since the company became the target of the New York attorney general's insurance kickback investigation.

It is a tax loss that can be used to eliminate capital gains taxes on the sale of other securities. It can also be employed to wipe away certain gains on real estate and to offset as much as $3,000 of ordinary income per tax year. And, the loss can be carried forward until it is used up.

"We always do tax-loss planning," says Peter Traphagen, CPA and personal financial specialist with Traphagen Advisors, LLC in Oradell, N.J. "There's no reason not to take a tax loss."

That's because the tax code allows you to have your loss and, with a little short-term shuffling, keep your stock or mutual fund, too. (Remember, however, this applies only to taxable investments, not to those held in tax-sheltered retirement accounts, like 401(k)s and IRAs.)

Let's say you bought 100 shares of

Merck

(MRK) - Get Report

a year ago when it was trading near $50 a share, before the price was hammered by the recall of its arthritis drug Vioxx. If you sold your shares at $26, you would have a loss of $2,400.

However, if you like Merck as a long-term investment and want to hold it in your portfolio, you can buy it back, as long as you don't violate the 30-day wash rule, which prevents you from claiming a loss, if you buy the same investment or a very similar one within 30 days.

You can, however, buy it back on the 31st day. To ensure that you don't miss a run-up in the drug sector before you can reinvest in Merck, Traphagen says, you could invest the sale proceeds in another pharmaceutical stock like

Johnson & Johnson

(JNJ) - Get Report

, a pharmaceutical mutual fund or ETF that would track with Merck for 30 days.

Meanwhile that $2,400 loss could be used to offset gains taken in your portfolio.

Traphagen says he's sold positions in

ExxonMobil

(XOM) - Get Report

, which has climbed from $35 to above $50 in the past 12 months, and bought

Colgate

(CL) - Get Report

, trading at a four-year low of about $47, after a recent pounding. The two stocks have comparable dividends, 2.15% and 2.47%, respectively.

"I didn't give up the dividend," he says, "and I have a greater chance to pick up appreciation."

Gains taken on investments held for less than one year are taxed at ordinary income rates, which can run as high as 35%. However, a short-term loss can offset both a short-term and long-term gain.

Care must be taken when selling one mutual fund at a loss and replacing it with a comparable one, says Scharin. The funds should not be too similar.

Switching from one high-tech fund to another would probably pass muster with the IRS, says Scharin. "Chances are there's going to be some difference in companies and weighting," he says. "The real gray area is when you're dealing with index funds."

So it's not a good idea to move from the

(VFIAX) - Get Report

Vanguard 500 Index Fund to a fund that also tracks the S&P 500 at another fund family.

Using software such as that put out by research firm Morningstar, says Traphagen, he can learn for purposes of tax-sale swapping which mutual funds have similar objectives and overlapping holdings, but don't overlap too much. As an example, he listed three funds (which happen to be faring well this year):

(OARBX) - Get Report

Oakmark Equity & Income Fund,

(ACEIX) - Get Report

Van Kampen Equity and Income and

(PAFDX) - Get Report

T. Rowe Price Equity-Income.

One caveat about buying into a mutual fund late in the year: Make certain you are purchasing after the "record date," when the fund makes its capital gains distribution. Otherwise you will most likely owe taxes on gains that you didn't receive.

Your tax losses can offset gains other than those from stocks and bonds. They can be applied to gains from real estate, whether from a rental property or your personal residence.

Because of the run-up in real estate prices in major metropolitan areas, some taxpayers find themselves exceeding the limits for tax-free capital gains when they sell their home. Homeowners are entitled to take tax-free profits of up to $250,000 if single and up to $500,000 if married on their principal residence, after living there two of the past five years.

Taking a stock tax loss would offset gains above those limits, says Sharon A. Dodson, CPA, of San Diego, who has begun to see clients exceed the real estate thresholds.

Losses can also be carried over from year to year, to be applied in part or in full to securities or real estate gains, until they are used up.

In addition, they can be carried forward each year and applied against ordinary income, up to $3,000 per year. For an individual in the second highest tax bracket of 33%, a $3,000 loss would save $990 in federal taxes.

"I have clients that will for life have a $3,000 loss," says Dodson, whose clients include investors who took large losses when the high-tech stock bubble burst. "I always say, 'Feel free to take a capital gain.'"

Reducing your income by $3,000 could help you qualify for certain income-based tax benefits, such as college savings and tax credit and the Roth IRA.