I am not an attorney and this is really a legal question. I highly recommend that you ask an attorney. Also, remember, everything is negotiable, so it never hurts to try to negotiate remaining in the property. I am just not sure you have the legal right to remain in the property.
I will only share my understanding of the intent of the law which protects tenants in a foreclosure situation.
In California, landlord-tenant law gives tenants the right to 60 days notice to quit if they have occupied the property at least one year (30 days if under one year). As foreclosures on rentals started to increase, tenants were not being given this 60 day notice. Many of them had been paying their rents to the owner, while the owner was not paying the mortgage. Quite a few of them paid the rents right up to and through the foreclosure. Then to add insult to injury, since the banks were not the holders of the tenant's security deposit, they were being thrown out of their homes without the benefit of a refund of their deposit.
In an effort to protect the innocent renter who paid their rents on time (note the protection only applies if the tenant is not in default under their lease / rental agreement) and who was not in any way responsible for the foreclosure, the law was passed to require the lenders to give legitimate tenants 60 days notice to quit. This law was in no way meant to "protect" the owner of the property who defaulted on their mortgage.
The bill that was passed is SB 1137. Here is an excerpt from that bill that seems to answer your question directly (see section b):
"SEC. 6. Section 1161b is added to the Code of Civil Procedure, to read:
1161b. (a) Notwithstanding Section 1161a, a tenant or subtenant in possession of a rental housing unit at the time the property is sold in foreclosure shall be given 60 days' written notice to quit pursuant to Section 1162 before the tenant or subtenant may be removed from the property as prescribed in this chapter.
(b) This section shall not apply if any party to the note remains in the property as a tenant, subtenant, or occupant.
Hope this helps answer your question and gives you a starting point to explore your options with an attorney. Dare to Dream.
Real Estate Consultant
RE/MAX Palos Verdes Realty