Here is how the current law reads:
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.
Here it is translated to plain English:
MGL 111, 127L
If there are poor conditions that may endanger or materially impair the health, safety or well being of the tenant or occupant and are so certified by the Board of Health or the landlord has been notified in writing and failed to start work within 5 days of such notice or substantially complete all necessary repairs within 14 days of such notice (or less if the Health Board Notice requires less time for repairs) then the tenant can repair and then withhold from the rent what it cost to repair. If the tenant chooses not to repair then they can break the lease, pay only the fair rental value taking into account the damages and vacate within a reasonable time.
The tenant cannot deduct more that 4 rents in a 12 month period. If the violations cover multiple units then the total deducted cannot exceed 4 months of rent in a 12 month period per unit.
The landlord can get back any amounts withheld by tenant in excess of 4 months rent or if the amount withheld by the tenant was unreasonable. To determine what is unreasonable one might look at 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 landlord cannot increase the rents due to cost of repairs or that might be viewed as retaliation but the court may order increase the rent temporarily to compensate for the amount they withheld unreasonably.
The tenant is not allowed to withhold rent to repair conditions or violations caused by them or a person associated with them. Also 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.
The tenants may have other rights under law. The tenant has no duty to repair or assume risk. The landlord is not relieved of any existing obligations or liabilities under law.
Any provision in a lease that waives the benefits of this section shall be null and void except in 2-yr leases where the tenant agrees to do certain repairs in exchange for a substantially lower rent.