In each of these consolidated appeals the plaintiff bank brought a summary process action against the former homeowner-mortgagor in the Housing Court after foreclosure. Each former homeowner raised various defenses and counterclaims in his or her answer to the complaint that challenged the bank’s right to both possession and title as derived through foreclosure sale, as well as other defenses and counterclaims. In each case the bank filed a motion to strike the affirmative defenses and to dismiss the counterclaims on grounds that the only defenses and counterclaims available in summary process are (1) those allowed by G. L. c. 239, § 8A, which does not apply here because there was no landlord-tenant relationship between the parties; and (2) a challenge to title (and thereby possession) based only on a failure to comply strictly with the power of sale provided in the mortgage. See Wayne Inv. Corp. v. Abbott, 350 Mass. 775, 775 (1966); New England Mut. Life Ins. Co. v. Wing, 191 Mass. 192, 195 (1906). A judge in the Housing Court acted on these motions after our decision in Bank of N.Y. v. Bailey, 460 Mass. 327, 334 (2011), where we said that the Housing Court has jurisdiction to consider an affirmative defense or a counterclaim raising the question of strict compliance with the power of sale in a mortgage as it relates to the title of a postforeclosure summary process plaintiff. On August 31, 2012, after deciding a similar motion in a case2 that he intended would serve as a guide for about two dozen other cases, the judge granted the motions of each bank as *615to landlord-tenant related defenses and counterclaims. He denied the motions as to the other defenses and counterclaims, concluding that the former homeowners were not limited to challenging title solely on the basis of strict compliance with the power of sale in the mortgage. The banks sought interlocutory review by a single justice of the Appeals Court. The single justice denied relief, but authorized an interlocutory appeal to a panel of the Appeals Court. See CUNA Mut. Ins. Soc’y v. Attorney Gen., 380 Mass. 539, 540 (1980). We granted the former homeowners’ application for direct appellate review. We affirm the decision of the Housing Court judge, and now hold that the Housing Court has jurisdiction to hear defenses and counterclaims that challenge the title of a plaintiff in a postforeclosure summary process action, which previously only could have been the subject of an independent equity action in the Superior Court, and that the Housing Court has authority to award damages in conjunction with such counterclaims.3
1. Background. The defendant former homeowners’ mortgages were foreclosed by exercise of the power of sale in their respective mortgages. Each plaintiff bank acquired title to a defendant’s home by foreclosure deed following a public foreclosure sale of the mortgaged premises. The banks then commenced these summary process actions in the Housing Court. Each complaint alleged that the former homeowner was holding over and occupying the “premises following a public foreclosure auction and beyond the time provided in the [njotice to [qjuit.” No party alleges the existence of, or bases any claim, defense, or counterclaim on the existence of, a landlord-tenant relationship.
The former homeowners filed answers to the complaints in which they raised various defenses and counterclaims.4 Matters *616raised only by way of affirmative defense include (1) allegations that the bank did not acquire title strictly according to the power of sale provided in the mortgage, see Wayne Inv. Corp. v. Abbott, supra; New England Mut. Life Ins. Co. v. Wing, supra; and (2) allegations of discrimination based on a failure to make the requested accommodation of a handicap.5 Matters raised only by way of counterclaim include (1) allegations of improper foreclosure and violations of G. L. c. 93A for which reinstatement of the mortgage is sought; and (2) allegations of improper foreclosure and violations of G. L. c. 93A for which damages for negligent and intentional infliction of emotional distress are sought. Matters raised by way of both affirmative defense and counterclaim include (1) allegations that a bank improperly failed to modify the mortgage loan pursuant to the Federal Home Affordable Modification Program, 12 U.S.C. §§ 5219, 5219a (2012), and that such failure constitutes a violation of G. L. c. 93A for which damages and reinstatement of the mortgage are sought; (2) allegations of discrimination based on national origin;6 (3) allegations that a bank violated G. L. c. 93A by offering to lease the house to the former homeowner but then never responded to the former homeowner’s attempts to pursue the bank’s offer; and (4) allegations of violations of the implied warranty of habitability, and breach of the covenant of quiet enjoyment.
The judge dismissed in general language the defendants’ affirmative defenses and counterclaims that were based on violations of the implied warranty of habitability, breach of the covenant of quiet enjoyment, theories of rent withholding, and other landlord tenant laws. He did not specify precisely which other defenses and counterclaims were included. He reasoned that those defenses and counterclaims did not apply in these cases because the former homeowners never claimed they had rented or leased the premises. No party challenges the correctness of this ruling.
The judge next addressed affirmative defenses and counter*617claims arising out of the banks’ assertions of title through foreclosure sale. In a lengthy and comprehensive decision in the case of Wells Fargo Bank vs. Amero, Northeast Hous. Ct., No. 12-SP-0870 (Aug. 31, 2012), that he made applicable to these cases by reference, the judge reasoned that a series of legislative enactments since 1974 that added and expanded the equitable jurisdiction of the District, Municipal, and Housing Courts in summary process cases, together with the adoption of the Massachusetts Rules of Civil Procedure in 1974 that produced a unified procedural system for legal and equitable causes of action, allow those courts to hear challenges to title of a post-foreclosure summary process plaintiff on grounds other than strict compliance with the terms of the power of sale, as had been the law under Wayne Inv. Corp. v. Abbott, supra, and New England Mut. Life Ins. Co. v. Wing, supra. He concluded that such challenges may now be raised in affirmative defenses and counterclaims for affirmative relief in a postforeclosure summary process action, and that a separate action in equity to set aside a foreclosure is no longer necessary.
2. Discussion. The banks argue that the sole authority for raising defenses and counterclaims in actions for summary process is found in G. L. c. 239, § 8A, and that § 8A expressly limits the use of defenses and counterclaims in summary process actions to those seeking “to recover possession of. . . premises rented or leased for dwelling purposes” (emphases added). Section 8A clearly governs summary process actions that arise out of a landlord-tenant relationship involving a dwelling. We have held that the absence of any reference to commercial tenancies in § 8A suggests a legislative intent to preclude the use of counterclaims in cases involving commercial tenancies. See Fafard v. Lincoln Pharmacy of Milford, Inc., 439 Mass. 512, 515 (2003). We have never had occasion to decide whether § 8A precludes defenses and counterclaims in other types of summary process actions, of which there are at least six, including postforeclosure summary process actions. G. L. c. 239, § l.7
The banks rely on Cummings v. Wajda, 325 Mass. 242, 243 *618(1950), where the court said “[sjummary process is a purely statutory procedure and can be maintained only in the instances specifically provided for in the statute,” and on Fafard v. Lincoln Pharmacy of Milford, Inc., supra, quoting Commonwealth v. McLeod, 437 Mass. 286, 294 (2002), where we said that a court may “not add words to [the] statute that the Legislature did not put there, either by inadvertent omission or by design.” They argue that the Housing Court judge impermissibly rewrote § 8A to effectively state that it applies in summary process actions “to recover possession of any premises rented or leased [or mortgaged] for dwelling purposes.”
Cummings, supra, does not exactly support the position of the banks. The issue in that case was whether a summary process action could even be instituted by the lessee of one joint owner of premises against the other joint owner, who was in possession of the premises. Id. at 243. The court held that because the circumstances did not reflect any of the enumerated instances for which summary process has been authorized by G. L. c. 239, § 1, the summary process action could not be maintained. Id. The case did not address defenses and counterclaims, or § 8A, whose predecessor first appeared in 1965, fifteen years after Cummings was decided. See St. 1965, c. 888.
Fafard, supra at 513, involved a summary process action commenced after termination of a commercial lease for nonpayment of rent. The tenant responded with an answer and counterclaim contending that the plaintiff, who had purchased the property from the prior landlord, owed the tenant money for improvements to the property and other payments made pursuant to a purchase and sale agreement between the tenant and the former owner. Id. at 513-514. We rejected the tenant’s argument that nothing in the statutory scheme prohibited reliance on G. L. *619c. 239, § 8A, as authority for bringing counterclaims in a commercial summary process action. Id. at 514. We said, “[bjecause a tenant’s right to bring a counterclaim is explicitly limited in § 8A to premises ‘rented or leased for dwelling purposes,’ it is clear that [§ 8A] applies only to summary process actions in residential cases” (emphasis added). Id. at 515. We declined to look beyond § 8A for authority of a commercial tenant to raise counterclaims in a summary process action because we concluded that by not including commercial tenancies in § 8A, “the Legislature meant to reject the right [to counterclaim] in commercial proceedings.” Id.
Fafard does not support the banks’ argument that § 8A governs defenses and counterclaims in all actions for summary process, and that if a defense or counterclaim is not expressly mentioned in § 8A, its omission should be deemed intentional. The focus of the court in Fafard was on “tenant counterclaims,” not counterclaims generally. See id. The holding was narrow, namely, that G. L. c. 239, § 8A, does not authorize counterclaims in summary process actions to recover possession of premises rented or leased for commercial premises. Fafard, supra.
The plain language of § 8A does not suggest a limitation on affirmative defenses and counterclaims in all summary process actions. It defines the scope of available claims and counterclaims only in that category of summary process actions that involves recovery of possession of “rented or leased” premises. Its legislative history suggests that it was intended to provide a defensive remedy (rent withholding) that complemented the affirmative remedy of enforcement of the State sanitary code, G. L. c. Ill, §§ 127C-127F, 127H (approved on same day as § 8A — January 7, 1966), “especially [for] poor tenants, [who] would not avail themselves of a remedy which required them to sue their landlords.” Boston Hous. Auth. v. Hemingway, 363 Mass. 184, 192-193 & n.7 (1973).
To the extent that the banks rely on the maxim of statutory construction that the expression of one thing in a statute is an implied exclusion of other things not included in the statute, their reliance is misplaced. The maxim is not a rule of law but an aid to interpretation, and it should not be applied where to *620do so would frustrate the general beneficial purposes of the legislation, see Brady v. Brady, 380 Mass. 480, 484 (1980), quoting Harborview Residents’ Comm., Inc. v. Quincy Hous. Auth., 368 Mass. 425, 432 (1975), or if its application would lead to an illogical result. See Suffolk Constr. Co. v. Division of Capital Asset Mgt., 449 Mass. 444, 458, 459 & n.19 (2007). The argument of the banks is undermined by several illustrations. First, the long-recognized defense, acknowledged by the banks, that a postforeclosure summary process action can be defeated if a plaintiff is unable to show that it acquired title strictly according to the power of sale provided in the defendant’s mortgage, see Bank of N.Y. v. Bailey, 460 Mass. 327, 333 (2011), is mentioned nowhere in G. L. c. 239, much less in § 8A. Second, in Boston Hous. Auth. v. Hemingway, supra at 199-203, this court held that defenses and counterclaims under common law for breach of the implied warranty of habitability were available to a tenant in a summary process action apart from any defenses and counterclaims available under § 8A.
Third, in 1974, District Courts were given limited equitable jurisdiction to consider defenses that in equity would “absolutely and unconditionally” relieve a defendant against a “plaintiff’s claim or cause of action or against a judgment recovered by the plaintiff in such action.” G. L. c. 231, § 31, as appearing in St. 1973, c. 1114, § 164 (portion of broad legislation that conformed General Laws to Massachusetts rules of civil and appellate procedure, also effective July 1, 1974). There is no other limitation, such as the unavailability of such defenses in certain types of civil actions. General Laws c. 231, § 31, was enacted independent of G. L. c. 239, § 8A, which was not amended to make reference to § 31. Section 31 allows a summary process defendant to raise equitable defenses in the District Court that may “absolutely and unconditionally” defeat the plaintiff’s claim. Such defenses are not limited to failure to comply strictly with the power of sale of a mortgage. They may include, without limitation, the defense of payment of the mortgage note. Although an equitable defense may not result in “affirmative relief,” e.g., setting aside the foreclosure sale, it may defeat the summary process action. See Mason v. Mason, 140 Mass. 63, 65 (1885) *621(“Even if equitable defenses, when complete, may be set up in a court of common law, all the powers of a court of equity are not imported into its proceedings”). Like the defense of failure to comply strictly with the power of sale in the mortgage, the defense of payment challenges the title of the summary process plaintiff and its right to possession.
Finally, it is highly unlikely that the Legislature intended to permit a tenant about to be evicted from his or her apartment to assert a wide range of defenses and counterclaims under § 8A in the Housing Court, but intended to significantly constrict the range of available defenses and counterclaims that a former homeowner about to be evicted from his or her home may assert in summary process, simply because the homeowner had a mortgage rather than a lease. For these reasons we conclude that § 8A is not the exclusive authority for defenses and counterclaims in summary process in the Housing Court.
We turn to the question whether claims that historically were required to be raised in a separate action in equity may be raised by counterclaim in the Housing Court. As discussed above, there is no question that the former homeowners can challenge the title of the banks in these summary process actions, and that they can require the banks to establish that title was acquired strictly according to the power of sale provided in the mortgage. It also is undisputed that a foreclosure sale may be set aside for other reasons in a separate action filed in a court of equity. Wayne Inv. Corp. v. Abbott, 350 Mass. 775, 775 (1966); New England Mut. Life Ins. Co. v. Wing, 191 Mass. 192, 196 (1906). Such an action challenges the title of one claiming ownership under a foreclosure deed, and if successful, a former homeowner could preclude or defeat an eviction. Since Abbott and Wing were decided there have been many changes in the jurisdiction of courts hearing summary process cases, including the Housing Court.
At the time Abbott and Wing were decided, summary process actions could be brought in the District Court or the Superior Court. See G. L. c. 239, § 2, as amended through St. 1960, c. 463, § l.A “separate action” in equity to challenge the foreclosure in ways other than strict compliance with the power of sale could not have been brought in the District Court because it did not have jurisdiction in equity. Although the “separate *622action” could be entered in the Superior Court pursuant to its general equity jurisdiction, see G. L. c. 214, § 1, the action nevertheless had to be separate from the summary process action even if both were filed in the Superior Court. The reason for this is that an action at law, including summary process, generally could not be joined with an action in equity. The “law” side of the court was separate and apart from the “equity” side of the court — they had separate docketing systems and separate rules of procedure. See J.R. Nolan & L.J. Sartorio, Equitable Remedies § 2.1, at 15-16 (3d ed. 2007); J.W. Smith and H.B. Zobel, Rules Practice §§ 2.1 & 2.2, at 36-37 (2d ed. 2006). Moreover, an equitable action generally could not be maintained by a petitioner who had an adequate remedy at law. See Bancroft Trust Co. v. Canane, 271 Mass. 191, 197-199 (1930). See also Jones v. Newhall, 115 Mass. 244, 247 (1874).
This changed with the adoption of the Massachusetts Rules of Civil Procedure in 1974, which unified the law and equity systems and created a single “civil action” in which legal and equitable remedies could be sought simultaneously. See Mass. R. Civ. P. 2, 365 Mass. 733 (1974). See also Reporters’ Notes to Rule 2, Mass. Ann. Laws Court Rules, Rules of Civil Procedure, at 11 (LexisNexis 2012-2013); Smith & Zobel, supra. The impact of Rule 2 is that separation of legal and equitable actions no longer is necessary if the court has both legal and equitable jurisdiction. Rule 13 of the Massachusetts Rules of Civil Procedure, as amended, 423 Mass. 1405 (1996), contemplates equitable counterclaims in actions formerly characterized as actions at law. Thus, since 1974, an equitable counterclaim to set aside a foreclosure for any legally recognized reason could have been filed in a postforeclosure summary process action in the Superior Court to challenge the plaintiff’s title.
The next Abbott and Wing development to follow was the grant of jurisdiction to the Housing Court, concurrent with the District and Superior Courts, in
“all civil actions . . . under . . . [G. L. c. 239 and] jurisdiction under the provisions of common law and of equity and any other general or special law, ordinance, by-law, rule or regulation as is concerned directly or indirectly *623with the health, safety, or welfare, of any occupant of any place used, or intended for use, as a place of human habitation and the possession [thereof].”
G. L. c. 185C, § 3, first par. Summary process actions under G. L. c. 239 are “civil actions,” Nalbandian v. Patruzzi, 369 Mass. 477, 477-478 (1976), and this quoted portion from c. 185C, § 3, is broad enough to include the power to consider equitable defenses under G. L. c. 231, § 31, as a supplement to the jurisdiction of the Housing Court in all summary process actions in which a plaintiff seeks to evict someone from a place of habitation.
In addition, the Housing Court has been given power to grant affirmative equitable relief in limited circumstances.8 General Laws c. 185C, § 3, second par., gives the Housing Court
“[i]n all matters within her jurisdiction, ... all the powers of the superior court department including the power to grant temporary restraining orders and preliminary injunctions as justice and equity may require” (emphasis added).
Although the equitable jurisdiction of the Housing Court is limited, see St. Joseph’s Polish Nat’l Catholic Church v. Lawn Care Assocs., Inc., 414 Mass. 1003, 1003 (1993), it necessarily includes the power to grant affirmative equitable relief in summary process actions where an equitable defense to the plaintiff’s title has been raised under G. L. c. 231, § 31.9 Thus, when the jurisdiction of the Housing Court has been invoked in a summary process action and the validity of a mortgage foreclosure has been made an issue insofar as it affects the plaintiff’s *624title, the Housing Court has equitable jurisdiction to enjoin or set aside a foreclosure sale that could have been ordered by the Superior Court in an independent action. A judge in the Housing Court is not constrained simply to deny the plaintiff possession of the premises. The “affirmative relief in equity,” which was required by New England Mut. Life Ins. Co. v. Wing, supra, in 1906, and affirmed by Wayne Inv. Corp. v. Abbott, supra, in 1966, to set aside a foreclosure sale for reasons other than failure to comply strictly with the power of sale provided in the mortgage, formerly available only in the Superior Court, is now available in the Housing Court as well.10
As noted above, summary process actions are “civil actions.” See Nalbandian v. Patruzzi, supra. Unlike most other types of civil actions, summary process actions are governed by a distinct set of rules: the Uniform Summary Process Rules. Although such actions are not governed by the Massachusetts Rules of Civil Procedure, see Mass. R. Civ. P. 81 (a) (1) (7), as amended, 450 Mass. 1405 (2008), procedures in actions for summary process “that are not prescribed by [the Uniform Summary Process Rules] shall be governed by the Massachusetts Rules of Civil Procedure insofar as the latter are not inconsistent with these rules, with applicable statutory law or with the jurisdiction of the particular court in which they would be applied.” Rule 1 of the Uniform Summary Process Rules (2012). Where the Housing Court has equitable power to afford affirmative equitable relief formerly available only in the Superior Court with respect to reopening foreclosure actions or enjoining foreclosure, and where Mass. R. Civ. P. 13 provides for counterclaims, it makes no sense to require a former owner to file a separate action to challenge a postforeclosure summary process plaintiff’s title when such relief should be available by way of counterclaim that is governed by the rules of civil procedure. This is consistent with the language of G. L. c. 185C, § 3, second par., which says the Housing Court has “all the powers of the superior court” in “all matters within their jurisdiction.”
*625Counterclaims in a postforeclosure summary process action are not limited to equitable claims. The Legislature has also given the Housing Court authority to consider claims in
“civil actions . . . under ... so much of [G. L. c. 93A] . . . as is concerned directly or indirectly with the health, safety, or welfare, of any occupant of any place used, or intended for use, as a place of human habitation and the possession [thereof].”
G. L. c. 185C, § 3, first par. Similar to the analysis above concerning equity jurisdiction, this grant of jurisdiction is limited. See LeBlanc v. Sherwin Williams Co., 406 Mass. 888, 895-897 (1990) (traditional product liability action involving manufacture of lead paint would dilute expertise of Housing Court). See also Ryan v. Kehoe, 408 Mass. 636, 640-641 (1990) (plaintiff’s complaint must have some relationship to original and special function of Housing Court). If the c. 93A claim is grounded in the validity of the title of the summary process plaintiff, a fundamental aspect of its right to possession, and if the elements of a c. 93A claim otherwise are met, the claim would fall within the limited jurisdiction of the Housing Court. General Laws c. 93A, § 9 (1), provides that a claim within the jurisdiction of the Housing Court may be presented in a counterclaim, and that equitable relief, monetary damages, attorney’s fees, and costs may be awarded.11
To the extent that any of the defendant former homeowners has stated a claim for unlawful discrimination under G. L. c. 151B that could vitiate the title, or possession, of the plaintiff bank seeking his or her eviction, the Housing Court has been given jurisdiction to award equitable relief, damages, attorney’s fees, and costs. See G. L. c. 151B, § 9. We see no reason why *626such a claim could not be presented to the Housing Court in a counterclaim in a postforeclosure summary process action.
The extent to which the rules of civil procedure are applied to a summary process action must not be inconsistent with the Uniform Summary Process Rules. The guiding principle, as stated in rule 1 of the Uniform Summary Process Rules, is that the rules of civil procedure “shall be construed and applied to secure the just, speedy, and inexpensive determination of every summary process action.” Judges in the Housing Court have considerable discretion to tailor the rules of civil procedure to this objective of summary process. Rules permitting pretrial motions and limited discovery with respect to summary process counterclaims seeking equitable relief and damages under G. L. c. 239, § 8A, can easily be applied to the kinds of counterclaims discussed here. See Rules 6 & 7 of the Uniform Summary Process Rules. The plaintiff banks’ fear of protracted litigation is not supported by any evidence that appreciably more time will be required to litigate defenses and counterclaims in a postforeclosure summary process action than is required to litigate similar defenses and counterclaims that regularly arise under G. L. c. 239, § 8A, in a landlord-tenant summary process action, including those that seek equitable relief and damages under G. L. cc. 93A and 151B. This approach was anticipated in the recent case of Bank of N.Y. v. Bailey, 460 Mass. 327, 334 (2011), and it is consistent with desirable considerations of judicial economy. We conclude that the Housing Court has jurisdiction to hear defenses and counterclaims that challenge the title of a postforeclosure summary process plaintiff, which previously only could have been the subject of an independent equity action in the Superior Court, and that the Housing Court has authority to award damages in conjunction with such counterclaims.
The decisions of the Housing Court are affirmed, and the cases are remanded for further proceedings consistent with this opinion.
So ordered.