The time is limited for homeowners who want to ensure they aren’t hit with a big tax bill because they had to walk away from a mortgage obligation.

At the height of the housing crisis, when foreclosures across the country began a troubling increase, Congress passed the Mortgage Forgiveness Debt Relief Act of 2007, designed to provide at least some consolation to folks who had lost their homes.

If you borrow money and the lender then cancels or forgives the debt, you generally have to include the canceled amount as income for tax purposes. As the IRS explains, you aren’t taxed on borrowed money because you have an obligation to repay it. However, if the debt is wiped out, the lender is then required to report the amount of canceled debt to you and the IRS on a Form 1099-C, Cancellation of Debt.

You can imagine the frustration that many people had with this seemingly unfair tax rule. They had lost their homes and then discovered in a “you’ve-got-to-be-kidding-me” moment that they owed taxes on the forgiven debt.

That’s where the mortgage debt relief act comes in. It allows people to exclude income from the discharge of debt on their principal place of residence. In addition to foreclosure, debt reduced because of a mortgage restructuring also qualifies for relief under the new law.

As always, there’s a catch.

The law says that only debt forgiven in calendar years 2007 through 2012 is eligible. Up to $2 million of forgiven debt qualifies for this exclusion ($1 million if married filing separately).

To get the relief, debt must have been used to buy, build or substantially improve a principal residence and be secured by that residence. So if you refinanced and took money out of the house to pay off credit card debt, you won’t receive the exclusion. Debt forgiven on second homes, rental property, business property, credit cards or car loans also does not qualify for the tax relief.

If you’re clinging to your house but it’s looking as though you won’t be able to hang on, the best time to get out from under the mortgage is before the debt relief law sunsets. This is particularly true if you are thinking about a short sale. That’s when the lender allows the borrower to sell the house for less than what is owed. Often, the borrower can negotiate to have the remaining balance on the mortgage forgiven.

Some states have made it easier for folks to go through the short-sale process. For example, a new law in California says that if lenders agree to a short sale — whether they hold a first or second lien — they have to forgive all outstanding loan balances.

The tax rule has become particularly important as more homes are sold through short sales, which accounted for 12 percent of all housing sales in the second quarter, up from 10 percent for the same period last year, according to RealtyTrac.

However, here’s the problem if you wait too long to start the process: Short sales are being dragged out for months. Talk to real estate professionals and many might suggest the term short sale be changed to “long sale.” I’ve seen several people who wanted to buy a home through a short sale walk away because the transaction was moving too slowly.

Pre-foreclosures sold in the second quarter took an average of 245 days to sell after receiving the initial foreclosure notice, according to RealtyTrac.

In a survey released earlier this year, 71.9 percent of real estate agents interviewed reported that a short sale could take four to nine months to complete, according to Equi-Trax Asset Solutions, a company that provides property valuations. Almost 10 percent of short-sale transactions require more than 10 months to complete.

When agents are asked to select ways to make short sales easier, 57.6 percent think lenders should move faster to close the transactions.

A short-sale survey conducted by the California Association of Realtors found similar results. More than three-fourths (77 percent) of California real estate agents reported closing short-sale transactions as “difficult” or “extremely difficult,” the group said.

You shouldn’t rush into a short sale or let your home go to foreclosure just to avoid a tax debt. But the impending end of the favorable tax rule on forgiven mortgage debt should be one of the things to consider if you conclude you can’t afford to keep your house.

Readers can write to Michelle Singletary c/o The Washington Post, 1150 15th St., NW, Washington D.C. 20071. Or e-mail: singletarym@washpost.com. Personal responses may not be possible. Please also note comments or questions may be used in a future column, with the writer’s name, unless a specific request to do otherwise is indicated.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.

To pause and restart automatic updates, click "Live" or "Paused". If paused, you'll be notified of the number of additional comments that have come in.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.