Section 127L. When violations of the standards of fitness for human habitation as established in the state sanitary code, or of other applicable laws, ordinances, by-laws, rules or regulations, may endanger or materially impair the health, safety or well-being of a tenant of residential premises and are so certified by the board of health or local code enforcement agency, or in the cities of Boston, Worcester and Cambridge by the commissioner of housing inspection, or by a court of law, and if the owner or his agent has been notified in writing of the existence of the violations and has failed to begin all necessary repairs or to contract in writing with a third party for such repairs within five days after such notice, and to substantially complete all necessary repairs within fourteen days after such notice, unless a board of health, local code enforcement agency or court has ordered that said violations be corrected within a shorter period, in which case said period shall govern, the tenant or tenants may repair or have repaired the defects or conditions constituting the violations. The tenant or tenants may subsequently deduct from any rent which may subsequently become due, subject to the provisions of the following paragraph, an amount necessary to pay for such repairs. The tenant or tenants may, alternatively in such cases, treat the lease or rental agreement as abrogated, pay only the fair value of their use and occupation and vacate the premises within a reasonable time.
A tenant may not deduct pursuant to this section an amount greater than four months' rent in any twelve-month period, or period of occupancy, whichever is shorter, from rent due to the owner. Such amount shall be computed on the basis of the highest monthly rent during the tenant's occupancy or during the twelve-month period before the violation is repaired, whichever is shorter. Where the violation affects more than one unit of a multi-unit structure, or a portion of the structure reserved for the common use of tenants, the amount deducted for repairs for all affected tenants shall not exceed the total of four months' rent due to the owner from all affected tenants. Failure to exercise any rights under this section in any twelve-month period shall not increase a tenant's rights in any subsequent twelve-month period.
The owner may recover from the tenant any excessive amount deducted from the rent. The amount deducted shall be excessive to the extent that it exceeded four months' rent as calculated pursuant to the preceding paragraph, or if it was unreasonable under all the circumstances. The criteria for unreasonableness shall include, but are not limited to, the alternatives available to the tenant at the time the violations were first reported, the urgency of the need to repair, and the quality and cost of the work done. Any excess deducted may be recovered in an action in contract, but not in an action for possession of the rental premises. The terms of such recovery may include an increase in rent for such future periods as the court may order. No owner may increase rents because of repairs made pursuant to this section, except pursuant to such a court order, and the provisions of section eighteen of chapter one hundred eighty-six shall apply to any such increase in rent.
The rights afforded tenants under this section shall not extend to conditions or violations caused by a tenant or by a person in the family or household of a tenant or by a business invitee or guest of a tenant. A tenant may not invoke the protection of this section if he has unreasonably denied the owner access to the dwelling unit and thereby prevented the owner from making necessary repairs.
In no case may the rights afforded a tenant under this section be construed to limit any other remedies available to him by law, or to impose a duty on him to repair, or to create or imply an assumption of any risk by the tenant; nor shall they relieve a landlord of any existing duty or liability under the state sanitary code or other applicable statutes, rules, regulations, by-laws, or ordinances.
Any provision of a residential lease or rental agreement whereby a tenant, lessee, or occupant enters into a covenant, agreement or contract, the effect of which is to waive the benefits of any provision of this section, shall be against public policy and void; except that a covenant in any lease of two years' duration not counting any renewal periods, in which the tenant undertakes to make certain defined repairs or renovations in consideration for a substantially lower rent, shall not be against public policy nor void.