If you were renting from the old owner
A foreclosure does not end a residential tenancy automatically. New York law requires the new owner to give tenants written notice and generally allows them to stay at least for a period set by statute, and often until the end of a lease, and federal law adds its own notice protection for tenants in foreclosed properties. Tenants in rent-stabilized or rent-controlled apartments usually keep those protections through the foreclosure. Keep paying rent to whoever is entitled to it, and if you are unsure who that is, keep the money set aside and get advice rather than stopping payment altogether. Removal still requires a court case.
If you were the owner
After the auction closes and a referee's deed is delivered, the new owner usually serves the former owner with a notice to leave and, if the occupants remain, brings a court proceeding or asks the foreclosure court for an order putting it in possession. Many purchasers, including banks, offer what is often called cash for keys, a payment in exchange for leaving by an agreed date in good condition. Whether that offer is worth taking depends on your timing and whether any part of the foreclosure can still be challenged. A pending motion or appeal in the foreclosure case does not by itself stop the removal unless a court orders a stay.
Papers to have ready
Gather any notice from the new owner, the lease and rent receipts if you are a tenant, the foreclosure judgment and notice of sale if you were the owner, and anything showing the date of the sale. Our first job is to identify which group you fall into, what notice has actually been given, and how much time you realistically have. We also look at whether moving out by agreement, staying under your tenant protections, or asking the court for more time fits your situation.