Appeal from an order of the Supreme Court (Cobb, J.), entered March 14, 1996 in Columbia County, which granted plaintiff’s motion to dismiss a counterclaim.
Plaintiff commenced this action in December 1989 against defendant Larry Dye (hereinafter defendant) and others for, inter alia, foreclosure of a mechanic’s lien on real property located in the Town of Chatham, Columbia County, and breach of an oral contract. Defendant answered and asserted a counterclaim for willful exaggeration of a lien. A note of issue dated March 30, 1992 was filed in this action and subsequently on June 30, 1992 defendant filed a chapter 7 petition (11 USC) in bankruptcy which failed to list the counterclaim against plaintiff as an asset of his bankruptcy estate. Defendant was subsequently discharged, in bankruptcy in May 1993.
*920The trial apparently commenced in March 1994, and on February 9, 1996 plaintiff moved to dismiss the counterclaim on the ground that defendant did not have the legal capacity to sue on said counterclaim. Supreme Court granted the motion, finding that although plaintiff should have moved prior to trial to dismiss or amend its answer to raise such a defense, under the circumstances presented equity dictated that the motion to dismiss the counterclaim be granted. This appeal by defendant ensued.
Initially, it is well settled that a debtor’s failure to list a legal claim as an asset in his or her bankruptcy proceeding causes the claim to remain the property of the bankruptcy estate and precludes the debtor from pursuing the claim on his or her own behalf (see, Dynamics Corp. v Marine Midland Bank-N. Y., 69 NY2d 191, 196-197; Robinson v Wiertel Constr., 185 AD2d 664, 665; DeLarco v DeWitt, 136 AD2d 406, 408). Thus, in this case, because defendant failed to list the counterclaim as an asset in his bankruptcy petition, he was without legal capacity to pursue the counterclaim (see, Matter of C & M Plastics (Collins), 168 AD2d 160, 161; Ervolino v Scappatura, 162 AD2d 654, 655).
Although the affirmative defense of lack of capacity to sue is generally waived by a plaintiff’s failure to raise it in a motion to dismiss or in a responsive pleading (see, CPLR 3211 [a] [3]; [e]), there was no waiver here since defendant’s lack of capacity did not arise until well after issue had been joined in the action. Defendant argues, nonetheless, that plaintiff waived the defense of lack of capacity to sue by failing to raise it prior to trial. In our view, even if plaintiff should have moved to dismiss or amend the pleadings to raise lack of capacity in a more timely manner (see, Thomas v Grupposo, 73 Misc 2d 427), under the particular circumstances of this case we do not find that Supreme Court erred in granting the motion. As Supreme Court found, "allowing defendant * * * to proceed on his counterclaim, which is inextricably intertwined with plaintiff’s causes of action, while prohibiting plaintiff from recovering from defendant in contract based upon defendant’s discharge in bankruptcy would be grossly inequitable”. Accordingly, we affirm Supreme Court’s order dismissing the counterclaim.
Mikoll, J. P., Casey, Spain and Carpinello, JJ., concur. Ordered that the order is affirmed, with costs.