Wondering how to stop foreclosure? If you're more than 90 days behind on your mortgage payments, your lender is probably knocking (or putting a foreclosure notice) on your door right about now. The good news? You won't lose your home overnight. There are multiple ways to stop foreclosure and protect your home—or, at the very least, your credit.

What is foreclosure?

According to the law, signing a mortgage as a buyer means you promise to pay your lender the amount of money you borrowed (over a period of time stipulated in your loan contract). If you renege on that promise, your lender is allowed—by law—to reclaim your home and sell it to recoup its money. The process of a lender repossessing the house due to lack of payment is foreclosure. But how do you stop all of that from happening? How do you keep your home from being reclaimed by the bank?

How to stop foreclosure

The simplest answer is to make any overdue payments to bring your loan current. That doesn't mean you have to pay off your entire mortgage, just all the late payments you owe. If you can bring it to that point, the pre-foreclosure process stops, and you return to a state of simply paying your mortgage on a regular basis.

So how long do you have before you are forced to leave your home? It varies by state.

"The amount of time you have between a notice of foreclosure and actually being forced to leave your home depends on where you live," says Michele Lerner, a real estate expert and author. That window varies from just 30 days to 60 days, depending on the jurisdiction.

"If you live in one of the 22 states that have 'judicial' foreclosure, which requires a court to determine whether the foreclosure is legitimate, this can slow down the process a little longer than in states with 'nonjudicial' foreclosure, which doesn't require a court procedure," she adds.

But no matter the length of the deadline, if you have the funds to pay your past-due bills, do it quickly.

What to do when you can't pay your mortgage

If you're struggling to make mortgage payments, you need to swallow your fears and call your lender immediately. It may be possible to save your home through a forbearance or loan modification, says Bill Richardson, district sales manager for The Keyes Company, a real estate agency in Boca Raton, FL.

With a forbearance, a lender agrees to temporarily suspend your payment responsibilities. This is not free money—it'll be tacked onto the end of your loan—but it could give you a chance to get your finances back on track.

If you've had an income change that's created the hardship, the lender might be willing to review your finances and redraft your mortgage, adding time onto the overall loan in order to lower your monthly payments.

"The most important thing you can do right now is focus all your efforts on assuring your lender that you can and will repay your home loan, so start making payments immediately and actively seek an appointment with a counselor or your lender to discuss your options," Lerner says.

The U.S. Department of Housing and Urban Development's Home Affordable Modification Program may also be an option for you. Administered by Fannie Mae, the program is designed to keep families in their homes and includes access to free counseling services for struggling homeowners.

Short sale

If you don't foresee ever being able to make your mortgage payments—even with a loan modification—one final option to stop a foreclosure is to ask your lender for permission to hire a real estate agent for a short sale. If your lender agrees, you will then have to sell your home, and the proceeds from the sale will go to the bank to satisfy your loan. You will lose your home, but you will walk away without a foreclosure on your record.

What happens to your credit after foreclosure?

Homeowners facing foreclosure might also wonder how the process will affect their credit, even if they manage to stop the foreclosure process before it's finalized.

"It depends how the foreclosure is stopped," Richardson says. "Credit scores are based on late payments, among other things. A loan modification and short sale will both stop late payments."

That said, your credit will repair faster on a short sale "because you will be paid in full for less than the amount owed," Richardson says. Still, a short sale will leave you without a home, so it's up to you to determine which option is the lesser of two evils.

Updated from an earlier version written by Michele Lerner. 

For more smart financial news and advice, head over to MarketWatch.