After the housing bubble burst and the recession hit, many homeowners had trouble paying their bills. Some lost their homes, while others opted to sell their homes in a short sale. This gave buyers a great opportunity to purchase homes at less-than-fair market value.

In a short sale, the lender agrees to accept less than the balance due on the loan. The homeowner sells the property and walks away from the loan. When a buyer purchases the home in a short sale, he or she may face substantial back taxes, unpaid association dues, and other liens against the home, such as mechanics’ liens.

Now, as the housing market slowly recovers, many homeowners are selling their homes, including people who previously purchased short sales. While the tax consequences for a homeowner selling a home in a short sale are pretty clear—he or she may have to pay taxes on the forgiven loan balance—what happens when you sell a short sale you purchased is a little muddier.

If you purchased a short sale and are now ready to sell the home, the tax implications of the sale depend on whether you purchased the property to occupy or as an investment.

Investors face capital gains taxes on the sale of an investment property. Generally, even if the property is held for less than a year, the gains and losses are considered capital gains and losses. If you have held the property for less than a year, the gains are taxed at the same rate as your ordinary income. If you have the property for more than one year, you’ll pay a reduced long-term capital gains tax rate of between 0 percent and 20 percent. Deductions for losses are limited to $3,000 in excess of your capital gains.

For folks who flip many houses each year, this would be considered a business, reportable on Schedule C, and the profits would be subject to self-employment taxes. All of the capital losses would be deductible when they are realized (when you sell the home).

Homeowners who purchased a home in which to live are taxed differently. If you lived in the property as your main home for at least two years, you can exclude up to $250,000 of the profits from the sale, or $500,000 if you’re married filing jointly. You could face taxes on anything over that amount, but they would be at your long-term capital gains rate if you owned the home for more than one year.

To reduce gains when you sell your home, keep thorough records of the costs of all improvements made that have increased its value, from installing a pool to remodeling the kitchen. You may want to sell in a year that your taxable income put you into a tax bracket of 15 percent or less. That way, your gains could be tax-free.

Eva Rosenberg, EA is the publisher of TaxMama.com ®, where your tax questions are answered. She is the author of several books and ebooks, including Small Business Taxes Made Easy. Eva teaches terrific courses that might help individuals and small businesses at CPE Link.