Bankruptcy does not necessarily prevent a foreclosure, but it can delay it. Filing under Chapter 13 can allow you to keep your home by integrating your debt on the mortgage into your repayment plan. This assumes that you have sufficient income to keep up with monthly payments under the plan. If you need to file under Chapter 7, however, you probably can expect only to delay rather than prevent a foreclosure. The automatic stay that accompanies a bankruptcy will pause foreclosure efforts until the lender gets permission to lift the stay and proceed with the foreclosure. Delaying the process still can be useful in giving you time to plan a move.