If you lose your house to foreclosure, you don’t necessarily have to lose all hope. And if you are thinking about buying a place that has been repossessed by a lender, you might want to think twice. What we’re talking about here is called the “statutory right of redemption.” Simply put, it gives a former owner whose property has been taken back in a foreclosure proceeding the ability to redeem the mortgage and keep said property — if, within a prescribed time frame, the former owner is somehow able to come up with enough money to repay what was owed.

All of us have the right to save our homes from foreclosure by paying off the entire mortgage balance, plus fees and costs, prior to the foreclosure sale, no matter where we live. But in many states, the law gives us the right to redeem our homes for a period of time after the foreclosure, usually by paying the foreclosure sales price plus interest and allowable fees.

In those states, consequently, owners can get their homes back even if they’ve been sold to someone else. In other words, not only can you retrieve your house, the unsuspecting buyer who bought it may have to give it up — even if their family has already moved in.   Each state has its own rules regarding redemption, so it is impossible to cover every one here. Legal website Nolo has a chart detailing the law in each state: nolo.com/legal-encyclopedia/50-state-chart-key-aspects-state-foreclosure-law.html. You also can obtain more information on the law in your state by contacting someone in county government who handles foreclosures.

But generally, there are two separate rights of redemption:

— Equitable. No matter which state you live in, you have the right to save your house right up to a foreclosure sale. This often proves difficult: After all, why would you be in foreclosure if you have the dough to pay off the entire loan? But you can try to refinance the mortgage with another lender or sell the place to someone else.

— Statutory. About half of the states allow people to reacquire their homes for a period of time after it is repossessed. Time frames vary. In some, the right lasts for only one month; in other states, a couple of years.

If you want to exercise this right, legal folks suggest having a commitment for a new loan, or even a loan itself, in place when you do so. They also advise obtaining a pro forma commitment from a title company and having all title issues resolved beforehand.    If your home sells at a foreclosure auction for a price far below its fair market value, you may be able to recoup your equity by redeeming the property for the foreclosure sale price, selling it to someone for the fair market value and pocketing the difference.

The statutory right of redemption isn’t exercised very often. But if it is, and you are on the other end of the redemption process — in other words, you bought the foreclosed property and the previous owner exercises his or her right to fetch it back — you should be reimbursed for what you paid for the property, the value of any improvements that you made, plus costs such as interest and taxes you paid on it.    Procedures vary by state. But according to LegalMatch, a licensed attorney-finding website, the process starts when the original owner makes a written demand to the buyer for a statement of charges required to redeem the property. The buyer has about 10 days to comply. Then, the first owner can file a claim and pay the redemption price. However, if the first owner fails to pay, they forfeit their right of redemption, and the buyer acquires the title to the property and all rights and interests in it. And if the original owner is still in possession of the property, he or she must vacate or face eviction — or, even worse, trespassing charges.

A way for buyers to get around the possibility that the owner will exercise their statutory right of redemption is to buy the redemption rights from the owner. You can do this shortly before or after you purchase the place at auction, at a cost that is totally negotiable. In many cases, someone facing foreclosure who sees no realistic way to avoid losing the house or recovering the property will be happy to sell rights they never expect to use.

What you have read here is for informational purposes only, and should not be taken as legal advice. If you find yourself in this predicament, you should secure legal counsel right away.

While on the topic of redemption, owners whose properties have been levied upon by the Internal Revenue Service for failure to pay their federal income taxes have the right to pay off that lien prior to the house being sold. If you do so, all further proceedings will stop.   After the house is sold, the tax law gives you the right to redeem it up to 180 days after the sale by paying the IRS what you owe and paying the buyer what they paid for the house, plus 20 percent interest per annum.   (Lew Sichelman has been covering real estate for more than 50 years. He is a regular contributor to numerous shelter magazines and housing and housing-finance industry publications. Readers can contact him at lsichelman@aol.com.)