When a lender forecloses on a home, it can choose to either forgive any remaining debt or pursue the homeowner for a deficiency judgment. If the lender chooses to forgive the debt, which is often the case, it will send a form 1099-C to the homeowner for the amount of debt that was forgiven.
This 1099 "income" would typically be included as income on your federal tax return, but the Mortgage Forgiveness Debt Relief Act of 2007 has become a lifesaver for many cash-strapped consumers that just can't afford a huge tax bill on income they never actually received. According to the law, the debt that remains after foreclosure can usually be excluded from your income if the loan was secured by your primary residence.
That's the good news. The bad news is the law as it currently stands only applies to the calendar years from 2007 through 2012.