You should contact a real estate attorney and check out what he has to say in this matter. After that you can contact the lender and discuss your situation and ask him to allow you to stay as a renter in the property. You can even try striking an agreement with the lender so that you can rent the property even after foreclosure.