If your landlord can't pay the mortgage and your apartment building goes into foreclosure, you won't be on the street tomorrow, thanks to a tenant-friendly federal law that took effect on May 20, 2009.
The Protecting Tenants at Foreclosure Act of 2009, which is Title VII of the Helping Families Save Their Homes Act, applies to the entire United States and broadly covers "any foreclosure on a federally related mortgage loan or on any dwelling or residential real property" and "any successor in interest to such property" (emphasis added).
Your right to stay in your apartment in the event of a foreclosure depends on whether you have a lease.
If You Don't Have a Lease
If you're living in your apartment without a lease, you have at least 90 days after the date of the foreclosure to vacate your apartment.
If You Have a Lease
If you've signed a lease for a term that ends after 90 days from the date of foreclosure, you can continue occupying your apartment all the way to the end of your lease term.
For example, say you just renewed the lease for your apartment for twelve months and your building was foreclosed on yesterday. You can stay in your apartment until your lease expires, which is roughly a year from now.
If your lease term ends before 90 days following the foreclosure, then you have the full 90 days.
Exception for primary-residence purchaser. If the building is sold in foreclosure to a purchaser who wants to use your apartment as her primary residence and you have a lease, then your lease expires on the date of the sale. However, you then have 90 days to continue occupying your apartment and start looking for a new rental.
Note: Unless Congress acts to extend the law, the Protecting Tenants at Foreclosure Act of 2009 is set to expire on December 31, 2012.