Motion for possession. Casey argues that she is entitled to *749reinstatement of her tenancy pursuant to G. L. c. 239, § 8A.6 The statute allows a tenant to withhold rent because of conditions “that . . . endanger or materially impair the [tenant’s] health, safety or well-being.” G. L. c. 239, § 8A, third par., as amended by St. 1977, c. 963. Generally, if the final disposition of the matter results in a judgment in favor of the landlord, the tenant has one week to reinstate her tenancy by paying the amount of the judgment into court. The landlord, however, must be notified of any such condition before the tenant is allowed to withhold her rent. Here, the trial judge found that York did not have notice of the complained of conditions until September 4, 2001, some two months into Casey’s rent arrearage and after she had received a notice to quit. We have found no reason in our review of the evidence to dispute this finding and conclude, therefore, that it was not clearly erroneous. The statute states that “[w]henever any counterclaim or claim of defense under this section is based on any allegation concerning the condition of the premises . . ., the tenant or occupant shall not be entitled to relief under this section unless: (1) the owner or his agents, servants, or employees, or the person to whom the tenant or occupant customarily paid his rent knew of such conditions before the tenant or occupant was in arrears in his rent” (emphasis added). G. L. c. 239, § 8A, second par., as amended by St. 1987, c. 773, § 15.7 Casey cannot avail herself of the statute’s remedial provisions and protections in the absence of her compliance with its procedural requirements. She cannot withhold her rent without justification and expect to retain possession of the rented premises. In these circumstances, she could *750not retain possession of her premises even if York had breached the warranty of habitability. “If the tenant fails to follow c. 239, § 8A’s procedures, [her] refusal to pay some or all of the rent due will subject [her] to eviction proceedings to which [she] will have no defen[s]e. . . . [S]he cannot use the landlord’s [alleged] breach of the habitability warranty as a defen[s]e to a notice to quit for nonpayment of rent.” Boston Hous. Authy. v. Hemingway, 363 Mass. at 202-203.