Unless the buyer and tenant agree to change or end the rental agreement, it continues after the sale, and the buyer takes over the landlord's rights and duties under it. The sale itself does not end the tenant's right to occupy under the continuing agreement.
In a voluntary sale, the seller must transfer the tenant's remaining security deposit to the buyer before recording the deed. The seller must notify the tenant in writing of the new landlord's name, address, and phone number and of the deposit transfer. The buyer must accept the deposit and cannot require a new one during the rental agreement.
Within 30 days after the sale, the new owner must tell the tenant where to pay rent, that the rental agreement continues, and how much security deposit is being held.