Order, Supreme Court, New York County (Louis B. York, J.), entered October 16, 2007, which, insofar as appealed from as limited by the briefs, denied plaintiff’s motion for summary judgment and dismissed certain of her claims on the ground of statute of limitations, reversed, on the law, without costs, the dismissed claims reinstated, plaintiff granted summary judgment as to liability on those claims, and the matter remanded for a trial as to damages.
CPLR 3211 (e) explicitly provides that an objection or defense. based on the statute of limitations is waived unless raised in a responsive pleading or in a pre-answer motion to dismiss. Defendant failed to do either, and thus waived this defense (see Buckeye Retirement Co., L.L.C., Ltd. v Lee, 41 AD3d 183 [2007] [statute of limitations defense waived unless raised by aggrieved party]).
As defendant waived the affirmative defense of statute of lim*435Rations, Supreme Court erred in its sua sponte consideration of that defense (see Paladino v Time Warner Cable of N.Y. City, 16 AD3d 646, 647 [2005] [“court may not take judicial notice, sua sponte, of the applicability of a statute of limitations if that defense has not been raised”]).
While “courts generally allow pro se litigants some leeway in the presentation of their case” (Stoves & Stones v Rubens, 237 AD2d 280 [1997]), in this particular case it was error to treat defendant’s opposition to plaintiffs motion for summary judgment on damages as either a motion to amend defendant’s answer, or a cross motion for summary judgment based on the statute of limitations. “A motion for summary judgment 'on one claim or defense does not provide a basis for searching the record and granting summary judgment on an unrelated claim or defense’ ” (Baseball Off. of Commr. v Marsh & McLennan, 295 AD2d 73, 82 [2002], quoting Sadkin v Raskin & Rappoport, 271 AD2d 272, 273 [2000]). Concur—Saxe, McGuire and Acosta, JJ.
Gonzalez, P.J., and Román, J., dissent in part in a memorandum by Román, J., as follows: Well-settled law mandates an outcome, for the most part different from that which the majority holds and therefore, I dissent.
From February 3, 1992 through July 23, 1999, plaintiff made a series of personal loans to the defendant. Some of the loans were evidenced by promissory notes, others by checks. Notably, at his deposition, and in his affidavit in opposition to plaintiffs motion, defendant conceded that he did in fact borrow all the money alleged by plaintiff. A review of the record shows that with the exception of one promissory note, dated July 21, 1992, there is no indication as to when defendant was obligated to repay plaintiff the money borrowed or when, if at all, plaintiff demanded payment of the loans. The promissory note dated July 21, 1992, however, states that defendant agreed to repay a loan totaling $16,200 within 60 months of the note’s execution.
Flaintiff moved for summary judgment alleging that inasmuch as defendant admitted borrowing money from the plaintiff as well as his failure to repay the debt, plaintiff was entitled to summary judgment. Defendant opposed plaintiffs motion arguing that all but one of the loans made to him by the plaintiff were unenforceable as time-barred. Defendant conceded that plaintiffs loan of $1,950, made on July 18 and 23, 1999, evidenced by a promissoiy note dated July 23, 1999, was not time-barred. The motion court, acknowledging that defendant had not raised the statute of limitations defense in his answer, nevertheless found that this defense barred the majority of *436plaintiffs claims, with the exception of the loan made July 1999. In the absence of any motion by the defendant, the court directed judgment in defendant’s favor, with the exception of the loan made to defendant on July 18 and 23, 1999, in the amount of $1,950, as to which it directed judgment in plaintiffs favor. Plaintiff appeals, averring that the motion court erred in allowing defendant to interpose a statute of limitations defense, a defense defendant never asserted in his answer nor in a preanswer motion to dismiss. For the reasons that follow hereinafter, I believe that the law dictates a modification of the motion court’s decision, rather than, as concluded by the majority, almost wholesale reversal of the same.
Generally, when a defendant fails to plead the statute of limitations as a defense in his or her answer or fails to move for dismissal on that ground, via a pre-answer motion, the defense is ordinarily waived (see Dougherty v City of Rye, 63 NY2d 989, 991-992 [1984]; Fade v Pugliani/Fade, 8 AD3d 612, 614 [2004]). However, when a defendant fails to plead an affirmative defense, as required by CPLR 3211 (e) and 3018 (b), but nevertheless asserts that defense in connection with a motion for summary judgment, the waiver is said to be retracted and the court can grant, when the defendant is the movant, or deny, when the defendant is the opponent, summary judgment based upon the unpleaded affirmative defense (see Lerwick v Kelsey, 24 AD3d 918, 919-920 [2005]; Allen v Matthews, 266 AD2d 782, 784 [1999]; Adsit v Quantum Chem. Corp., 199 AD2d 899 [1993]). The threshold inquiry is whether in considering the unpleaded defense, the opponent of the defense is prejudiced thereby (see BMX Worldwide v Coppola N.Y.C., 287 AD2d 383 [2001]; Allen v Matthews, 266 AD2d 782, 784 [1999]; Seaboard Sur. Co. v Nigro Bros., 222 AD2d 574 [1995]; Rogoff v San Juan Racing Assn., 77 AD2d 831 [1980], affd 54 NY2d 883 [1981]). Such prejudice, however, is ameliorated when the defense was previously raised on a prior motion or during discovery (id.), or when the opponent of the motion, where defendant seeks summary judgment based upon said defense, is given an opportunity to fully respond to the motion for summary judgment (Sheils v County of Fulton, 14 AD3d 919 [2005], lv denied 4 NY3d 711 [2005]; Kirilescu v American Home Prods. Corp., 278 AD2d 457 [2000], lv denied 96 NY2d 933 [2001]; McSorley v Philip Morris, Inc., 170 AD2d 440 [1991], appeal dismissed 77 NY2d 990 [1991]; International Fid. Ins. Co. v Robb, 159 AD2d 687 [1990]).
In this case, the motion court properly considered defendant’s statute of limitations defense proffered for the first time in opposition to plaintiffs motion for summary judgment (Allen at *437784). In its decision, the motion court noted that defendant had “vigorously asserted such a defense” in his postanswer submissions, i.e., in opposition to plaintiffs motion for summary judgment. Additionally, a review of the record shows that plaintiff, who had ample opportunity to address the statute of limitations defense in reply to defendant’s opposition to her motion for summary judgment, never alleged that she was surprised or actually prejudiced as a result of defendant’s newly-raised defense. Accordingly, nothing precluded the motion court from considering the defense. The majority simply ignores the legion of cases, which create an exception to the well-settled rule related to affirmative defenses, waiver and motions for summary judgment.
The motion court thus erred not in procedurally awarding defendant relief but in substantively concluding, on this record, that all but one of plaintiffs claims are in fact time-barred.
When a court is deciding a motion for summary judgment, it can search the record and, even in the absence of a cross motion, may grant summary judgment to a nonmoving party (CPLR 3212 [b]; Dunham v Hilco Constr. Co., 89 NY2d 425 [1996]). Furthermore, a cause of action for breach of contract must be commenced within six years (CPLR 213 [2]). The cause of action accrues at the time of the breach (John J. Kassner & Co. v City of New York, 46 NY2d 544 [1979]). When the cause of action is one to recover a sum of money owed pursuant to contract, the cause of action accrues when plaintiff possesses the legal right to demand payment (see Verizon N.Y., Inc. v Sprint PCS, 43 AD3d 686 [2007]).
Based on the foregoing, the motion court providently exercised its discretion when it searched the record to determine whether, in light of defendant’s statute of limitations defense, any of plaintiffs claims were time-barred thereby meriting dismissal. Contrary to the majority’s decision and the cases cited therein, this was not an instance where the court, sua sponte, granted summary judgment on an issue never raised (see Buckeye Retirement Co., L.L.C., Ltd. v Lee, 41 AD3d 183 [2007]; Paladino v Time Warner Cable of N.Y. City, 16 AD3d 646 [2005]; Baseball Off. of Commr. v Marsh & McLennan, 295 AD2d 73 [2002]). Instead, the court granted summary judgment on an issue which, although defendant never pleaded, he did in fact raise in opposition to plaintiffs motion. However, insofar as the court concluded that virtually all of plaintiff’s claims were time-barred, the court erred as a matter of law.
With the exception of the loans governed by the promissory note dated July 21, 1992, which stated that it was to be repaid *438within 60 months and for which, therefore, the six-year statute of limitations would have expired on or about July 21, 2003, and the loan made July 18 and 23, 1999, which defendant concedes is not time-barred, on this record, there is no evidence as to whether that the statute of limitations has run with regard to the 12 remaining loans, since there is no evidence of any breach related thereto.
The motion court thus erred when it concluded that recovery on these 12 loans was time-barred. The record fails to indicate when, if at all, plaintiff was entitled to or demanded repayment of these loans. Thus, the record is bereft of any evidence as to when defendant breached each agreement so as to trigger the statute of limitations as to each of these loans. Accordingly, whether, claims as to these loans are time-barred is an issue of fact warranting denial of plaintiffs motion for summary judgment with regard to them.
Based on the foregoing, I believe that the motion court correctly granted plaintiff and defendant summary judgment on the July 1999 loan and on the July 21, 1992 promissory note, respectively. However, to the extent that it granted defendant summary judgment on the remainder of plaintiffs claims, the court erred. Accordingly, I would modify the motion court’s decision and order, to the extent of vacating its determination that defendant is entitled to summary judgment with regard to all the remaining claims asserted by plaintiff.