When a homeowner can not repay (defaults on) the mortgage and negotiations for an alternative payment plan fail, the lender has no choice but to start the foreclosure process. This process varies from state to state, but in general, a foreclosure is an auction either with or without court action. The sale must be advertised in local newspapers and the highest bidder wins the home. Since the lender only bids on what is owed, a buyer can often find a good deal, especially on an older home.
You still get one final chance to keep your home by paying off all delinquent costs either before the sale or in a judicial foreclosure, before the court approves the foreclosure. Having a foreclosure on your credit is very serious business, often worse than bankruptcy.