In addition to the lender and the defaulting owner, another party that stands to suffer greatly from the foreclosure of a residential property is the innocent tenant.
The suffering typically begins early, long before the foreclosure sale. Notices of Sale, appraisers and potential buyers begin appearing at the property much to the confusion of the tenant. Despite learning that a foreclosure may be imminent and a new owner may soon be in place, the tenant is bound by the terms of his rental agreement until such a transfer actually takes place. This places the tenant between a rock and a hard place: Should he abide by the terms of the lease agreement and risk being forced to leave on short notice by the new owner? Or should he break the lease agreement now and risk liability to the owner if the property is not ultimately foreclosed upon?
Once the property is sold at auction (or the property reverts back to the lender if no sale occurs), the new owner is entitled to possession and the tenant becomes a "hold-over" tenant. The sale terminates the existing tenancy and there is no landlord-tenant relationship between the new owner and the existing tenant. (There is a minor exception where the tenancy begins prior to the loan that is foreclosed upon and notice of the tenancy has been given to the lender, but that situation is rare).
In terms of money, rent owing before the foreclosure sale is payable to the new owner and although technically the new owner cannot demand that the tenant pay rent after the sale, the new owner can seek the "fair rental value" of the property in a subsequent eviction action.
The new owner can decide to continue the tenancy, but that is unusual, especially if the new owner is the lender bank. However, if the new owner does accept rent, the relationship between the two becomes a consensual month-to-month tenancy and the new owner becomes a landlord with all the duties and obligations of such. Because of this, many lenders are simply allowing hold-over tenants to live rent-free until the lender can get around to filing an eviction, which is sometimes several months.