Normally, if a lender forgives a debt (something that’s happened a lot more lately), that forgiven amount counts as income (which makes sense; you did get the money after all). But the 2007 Mortgage Forgiveness Debt Relief Act of 2007 exempts some of that debt (e.g., if it was "used to buy, build or substantially improve your principal residence and be secured by that residence") from taxation — potentially up to $2 million of debt forgiven on your principal residence.

The IRS has the details on its "Ten Facts for Mortgage Debt Forgiveness" page. Check it out.