
192 P.3d 513 (2008)
DINOSAUR PARK INVESTMENTS, L.L.C., Plaintiff-Appellant,
v.
Fernando TELLO, Defendant-Appellee.
No. 07CA0956.
Colorado Court of Appeals, Div. III.
July 10, 2008.
*514 Feldman, Nagel & Associates, LLC, Lynaia M. South Orr, Steamboat Springs, Colorado, for Plaintiff-Appellant.
The Law Office of Cheryl L. Hardy-Moore, P.C., Douglas S. Timmerman, Steamboat Springs, Colorado, for Defendant-Appellee.
Opinion by Judge J. JONES.
Plaintiff, Dinosaur Park Investments, L.L.C., appeals the district court's judgment in favor of defendant, Fernando Tello, on Dinosaur Park's breach of contract claim, and the court's order awarding attorney fees to Tello. We reverse the judgment and order, and remand the case for further proceedings.

I. Background
In 2004, Dinosaur Park and Tello entered into an installment land contract whereby Tello agreed to make monthly installment payments and partial tax and insurance payments to Dinosaur Park for the purchase of an apartment complex. Dinosaur Park agreed to provide $30,000 to Tello (who took immediate possession of the property) for improvements to the property, and Tello agreed to contribute $12,000 toward improvements.
Alleging that Tello failed to make timely monthly installment payments, Dinosaur Park filed an action in district court asserting claims for breach of contract and appointment of a receiver. Tello, acting pro se, filed an answer to the complaint which stated, in its entirety, as follows:

*515 In response to the lawsuit case number 05CV64 the charges against me Fernando Tello are false, payments have been made and they are the ones not compiling [sic] with the contract. They have offered me to stop this lawsuit in exchange of me signing a listing contract to put the property up for sale.
Some time thereafter, the parties agreed that Dinosaur Park could sell the property to a third party, and Dinosaur Park did so. In response to a motion for summary judgment filed by Dinosaur Park, Tello asserted that the agreement to allow Dinosaur Park to sell the property modified the installment land contract.
Less than three weeks before trial, Tello filed a motion for leave to assert a counterclaim for unjust enrichment. The court denied that motion because it was untimely.
The trial was set to begin on Monday, October 2, 2006 (sixteen months after Dinosaur Park filed its complaint). The Friday before the trial was to begin, Tello, through his recently retained attorney, filed a motion (purportedly under C.R.C.P. 11) asserting that the installment land contract was void, and seeking a declaration to that effect and other remedies. Tello's motion was premised on section 38-35-126(3), C.R.S.2007, which provides:
The buyer shall have the option of voiding any contract for deed to real property which fails to designate the public trustee as escrow agent for deposit of property tax moneys or for which no written notice is filed with the county treasurer's office or the county assessor's office. Upon voidance of such contract, the buyer shall be entitled to the return of all payments made on the contract, with statutory interest as defined in section 5-12-102, C.R.S., and reasonable attorney fees and costs. This avoidance right shall expire on the date seven years after the latest execution date on the contract for deed to real property unless exercised prior to such date.
The morning of the first day of trial, the court heard argument on whether Tello should be allowed to raise section 38-35-126 at trial. Dinosaur Park's counsel argued that (1) the statute is in the nature of an affirmative defense or counterclaim; (2) Tello had not timely raised the statute as an affirmative defense or counterclaim, and had therefore waived it; (3) Dinosaur Park would be prejudiced if Tello were permitted to raise the statute at trial because (a) it had not been able to conduct discovery on the issue, (b) it had not been able to prepare for trial on the issue, and (c) it would have additional claims and defenses related to the statute that it was not prepared to try (such as unjust enrichment relating to Tello's retention of rental payments while he was in possession of the property); (4) the statute was inapplicable because the property had been sold, thereby rendering the court unable to rescind the contract and put the parties in their original positions; and (5) Tello had effectively waived his right to void the contract because he had continually treated it as valid.
The court ruled that Tello would not be able to raise section 38-35-126 at trial, essentially agreeing with Dinosaur Park's latter two arguments. The case was tried to the court. After the parties had finished presenting their evidence, the court reiterated that it was not allowing Tello to assert any right under section 38-35-126.
In due course, the court issued its findings of fact, conclusions of law, and judgment. As relevant to this appeal, the court made the following findings of fact:
 Dinosaur Park did not timely provide the $30,000 for improvements.
 Tello's accounting for rents he received was poor, and hence Dinosaur Park could not present evidence of rents Tello retained.
 Tello defaulted on the contract by failing to make timely installment payments.
Notwithstanding these findings and its earlier ruling that Tello would not be permitted to raise section 38-35-126 at trial, the court ruled that Tello was entitled to rescind the contract under that statute. The court stated that it had erred in ruling on the first day of trial that Tello could not raise the statute. In an effort to place the parties in the positions they were in prior to entering into the contract, the court ordered Dinosaur *516 Park to reimburse Tello for certain expenses he incurred in improving the property, totaling $31,000.
The court subsequently ordered Dinosaur Park to pay Tello $10,000 for attorney fees he had incurred in connection with his claim under section 38-35-126. (Subsection 38-35-126(3) provides that a party who opts to void a contract for failure to comply with subsection 38-35-126(1) may recover "reasonable attorney fees and costs.")
Dinosaur Park filed a timely motion under C.R.C.P. 59 to amend the court's findings and judgment, contesting the court's reliance on section 38-35-126 because the court had barred Tello from asserting a claim based on that statute. The court denied the motion.

II. Discussion

A. Affirmative Defense, Compulsory Counterclaim, or Neither?
Because the issue impacts our standard of review as well as the law governing the resolution of Dinosaur Park's primary contention on appealthat the district court erred in allowing Tello to void the contract pursuant to section 38-35-126we must determine whether Tello's claim to void the contract was in the nature of an affirmative defense or compulsory counterclaim, as Dinosaur Park contends, or neither, as Tello contends. Tello takes the position that his claim pursuant to the statute cannot be regarded as an affirmative defense or compulsory counterclaim, and hence subject to any bar for failing to timely assert it in this action, because the statute provides a seven-year period of limitations to seek to void a contract. We conclude that Tello's claim pursuant to the statute was an affirmative defense and a compulsory counterclaim, and we reject Tello's argument.
An affirmative defense is "a legal argument that a defendant ... may assert to require the dismissal of a claim or to prevail at trial." State v. Nieto, 993 P.2d 493, 507 (Colo.2000); see Black's Law Dictionary 451 (8th ed.2004) (defining affirmative defense as "[a] defendant's assertion of facts and arguments that, if true, will defeat the plaintiff's... claim, even if the allegations in the complaint are true").
Clearly, Tello's claim that the contract was void under section 38-35-126 was an attempt to avoid liability on Dinosaur Park's breach of contract claim. It was not a mere denial of an element of Dinosaur Park's claim, but rather a defense to the claim notwithstanding Dinosaur Park's ability to prove the elements of its claim.
Moreover, the primary remedy Tello sought was rescission, which is a defense or claim which must be pleaded in accordance with C.R.C.P. 8. Ice v. Benedict Nuclear Pharmaceuticals, Inc., 797 P.2d 757, 760 (Colo.App.1990). Other jurisdictions have expressly held that rescission is an affirmative defense when raised to avoid liability on a breach of contract claim. See, e.g., Resnik v. Morganstern, 100 Conn. 38, 122 A. 910, 911 (1923); Joseph Bucheck Constr. Corp. v. Music, 420 So.2d 410, 414-15 (Fla.Dist.Ct. App.1982); Great Am. Ins. Co. v. General Builders, Inc., 113 Nev. 346, 934 P.2d 257, 262 (1997); Falcione v. Cornell School Dist., 383 Pa.Super. 623, 557 A.2d 425, 427-28 (1989); 9029 Gateway South Joint Venture v. Eller Media Co., 159 S.W.3d 183, 186 (Tex. App.2004). And, though C.R.C.P. 8(c) does not expressly identify rescission as an affirmative defense, its nonexclusive list of affirmative defenses includes theories that are conceptually and remedially similar to rescission, such as accord and satisfaction, failure of consideration, fraud, illegality, and the statute of frauds.
Under the circumstances here, Tello's claim that the contract was void under section 38-35-126 was also a compulsory counterclaim.
A claim is "the aggregate of operative facts which give rise to a right enforceable in the courts...." Corporon v. Safeway Stores, Inc., 708 P.2d 1385, 1388 (Colo.App.1985); see also Black's Law Dictionary 264 (defining claim as "[t]he assertion of an existing right; any right to payment or to an equitable remedy"). Because Tello sought to assert the statute in opposition to Dinosaur Park's claim, it was in the nature of a counterclaim. Transport Clearings of Colo., Inc. v. Linstedt, *517 151 Colo. 166, 167, 376 P.2d 518 (1962); see also Black's Law Dictionary 376.
C.R.C.P. 13(a) defines a compulsory counterclaim as:
any claim which at the time of filing the pleading the pleader has against any opposing part, if it arises out of the transaction or occurrence that is the subject matter of the opposing party's claim and does not require for its adjudication the presence of third parties of whom the court cannot acquire jurisdiction.
In applying this rule, we determine whether the defendant's claim has a logical relationship to the plaintiff's claim. Skyland Metropolitan Dist. v. Mountain West Enterprise, LLC, 184 P.3d 106, 124 (Colo.App. 2007); In re Estate of Krotiuk, 12 P.3d 302, 304 (Colo.App.2000). "Any claim that a party might have against an opposing party, which is logically related to the claim brought by the opposing party ... is a compulsory counterclaim." Visual Factor, Inc. v. Sinclair, 166 Colo. 22, 26, 441 P.2d 643, 645 (1968); accord Skyland Metropolitan Dist., 184 P.3d at 124. We look to "whether the claims involve all or many of the same factual and legal issues, or offshoots of the same basic controversy between the parties." McCabe v. United Bank of Boulder, 657 P.2d 976, 978 (Colo.App.1982); accord Skyland Metropolitan Dist., 184 P.3d at 124. "The test constitutes a broad, flexible, and practical standard, which prevents the filing of a multiplicity of actions and encourages the resolution of all disputes arising out of a common factual matrix in a single lawsuit." Skyland Metropolitan Dist., 184 P.3d at 124.
Tello's claim under the statute arose out of and related directly to the same contract Dinosaur Park sought to enforce against him. If Tello were to prevail on that claim, Dinosaur Park could not prevail on its claim. Logically, Tello's claim was related to Dinosaur Park's claim, and therefore was a compulsory counterclaim. Cf. Conopco, Inc. v. Roll Int'l, 231 F.3d 82 (2d Cir.2000) (claim for breach of contract was compulsory counterclaim in prior state court action on claim to rescind the contract); Montgomery Ward Dev. Corp. v. Juster, 932 F.2d 1378 (11th Cir.1991) (claim for reformation of contract was compulsory counterclaim in prior state court action on claim to determine the parties' rights under the contract); Grynberg v. Rocky Mountain Natural Gas, 809 P.2d 1091, 1092-93 (Colo.App.1991) (the defendant's claim for money due under a contract was a compulsory counterclaim to the plaintiff's breach of contract claim in a prior action).
We are not persuaded by Tello's argument that the right to void an installment land contract under section 38-35-126 cannot be an affirmative defense or compulsory counterclaim because the statute gives a party seven years to seek to void the contract. To accept that argument would contravene the rule of waiver, discussed below, pertaining to affirmative defenses and compulsory counterclaims: it would mean that a party could recover on a contract in a legal action before the court, only to be hauled into court sometime later in an action to void the same contract. This would result in a multiplicity of suits over the same subject matter and potentially inconsistent judgments.
We also observe that every civil claim in Colorado is subject to some statute of limitations. See § 13-80-102(1)(i), C.R.S.2007 (providing a two-year statute of limitations for "[a]ll other actions of every kind for which no other period of limitation is provided"). To hold that the existence of a statute of limitations renders a counterclaim noncompulsory would therefore lead to the conclusion that there are no compulsory counterclaims. Tello cites no support for this conclusion, and we are aware of none.

B. Propriety of the District Court's Ruling
Both an affirmative defense and a compulsory counterclaim must be asserted in a party's responsive pleading (or amended responsive pleading) or they are waived. Crocker v. Colo. Dep't of Revenue, 652 P.2d 1067, 1070-71 (Colo.1982); Duke v. Pickett, 168 Colo. 215, 218, 451 P.2d 288, 290 (1969); In re Estate of Krotiuk, 12 P.3d at 304. Tello concedes that he did not raise the statute in his answer, and in fact did not raise it until the Friday before trial. He has never asserted that he had any legitimate *518 explanation for failing to raise it earlier. In effect, the district court, after ruling immediately before trial that Tello would not be permitted to raise the statute, allowed Tello to avoid the consequences of his failure to plead the statute in his answer, and his failure to timely move to amend his answer, by permitting him to amend his answer after trial.
Amendment of pleadings is permitted and governed by C.R.C.P. 15. After a responsive pleading is filed, a party may amend his pleading by leave of the court or the opposing party's written consent. C.R.C.P. 15(a). In addition, a pleading may be amended to conform to the evidence at trial if the new issue is tried by express or implied consent of the parties. C.R.C.P. 15(b).
Here, Dinosaur Park did not consent, in writing, expressly, or impliedly, to try the issues whether the contract was void under section 38-35-126 and, if so, what remedies were appropriate. Dinosaur Park's objections to trying those issues were clear and consistent, and the parties did not present evidence pertaining to those issues at trial, except to the extent any such evidence was relevant to the claims that were tried. Therefore, C.R.C.P. 15(b) is not implicated here, and the question before us is whether the district court erred in reversing its earlier decision and allowing Tello to amend his answer after trial under C.R.C.P. 15(a). We conclude that it did.
The determination whether to allow a party to amend a pleading under C.R.C.P. 15(a) is committed to the district court's sound discretion. Polk v. Denver Dist. Court, 849 P.2d 23, 25 (Colo.1993). Accordingly, we will not reverse a district court's decision to permit such an amendment absent a showing of an abuse of that discretion. Id.
Where, as here, a defense or claim is not pleaded or intentionally and actually tried, a court cannot render a judgment thereon. Bill Dreiling Motor Co. v. Shultz, 168 Colo. 59, 61-65, 450 P.2d 70, 71-73 (1969); Maxey v. Jefferson County School Dist. No. R1, 158 Colo. 583, 585, 408 P.2d 970, 971 (1965); Savage v. Williams Production RMT Co., 140 P.3d 67, 72 (Colo.App. 2005); Haffke v. Linker, 30 Colo.App. 76, 78-79, 489 P.2d 1047, 1048-49 (1971); Corbin Douglass, Inc. v. Kelley, 28 Colo.App. 369, 380-81, 472 P.2d 764, 769 (1970); cf. Doubleday & Co., Inc. v. Curtis, 763 F.2d 495, 502-03 (2d Cir.1985) (court erred in dismissing the plaintiff's breach of contract claim based on the defense of waiver where that defense was not pleaded by the defendant or tried). This rule cannot be circumvented by allowing a party to amend his answer after trial where the defense or claim was not tried by express or implied consent. See Bill Dreiling Motor Co., 168 Colo. at 64-65, 450 P.2d at 72-73.
We further conclude the district court abused its discretion in effectively permitting Tello to amend his answer after trial because Dinosaur Park was clearly prejudiced. See Polk, 849 P.2d at 25-28 (amendment should not be permitted where delay in asserting claim is inexcusable and opposing party would be prejudiced); Ajay Sports, Inc. v. Casazza, 1 P.3d 267, 273 (Colo.App.2000) (leave to amend answer properly denied where party sought to amend shortly before trial and opposing party would have been prejudiced); Gaubatz v. Marquette Minerals, Inc., 688 P.2d 1128, 1129-30 (Colo.App.1984) (leave to amend answer to assert counterclaim was not proper where motion was filed shortly before trial and opposing party would have been prejudiced). Prior to and during trial, the parties proceeded on the theory that the contract was enforceable (though Tello alleged it had been modified). The evidence introduced at trial by both parties was consistent with that theory. The district court, however, decided the case on the basis of a radically different theorythat the contract was void and Tello was entitled to rescission. The court did not give Dinosaur Park notice that such a theory would be tried. Indeed, the court expressly told the parties the morning of trial that such a theory would not be tried. In reversing course after the end of trial, the district court deprived Dinosaur Park of the opportunity to structure its case so as to attempt to counter that new theory. Cf. Gaubatz, 688 P.2d at 1130 (where the plaintiff had proceeded until trial on a theory of specific performance, *519 court did not err in denying the plaintiff's motion to plead rescission; the defendant would have been prejudiced by the belated assertion of the radically different theory).
Further, the district court effectively precluded Dinosaur Park from seeking additional remedies to which it was entitled upon rescission of the contract. Where an installment land contract is rescinded under section 38-35-126, the party who sought enforcement of the contract is nonetheless entitled to recover the reasonable rental value of the property under a theory of unjust enrichment. Haan v. Traylor, 79 P.3d 114, 117-18 (Colo.App.2003).
Here, Dinosaur Park's counsel told the court on the morning of trial (when Tello's motion to raise the statute was heard) that it would assert an unjust enrichment claim in the event Tello was permitted to raise the statute at trial. Because the court refused to allow Tello to raise the statute at trial, Dinosaur Park did not assert an unjust enrichment claim. Had it known the court would permit Tello to raise the statute at trial, Dinosaur Park could have presented expert testimony on the reasonable rental value of the property. Though permitting Dinosaur Park to present such evidence would have required a continuance (as Dinosaur Park's counsel indicated), denying a continuance would have been an abuse of discretion because (1) Tello did not raise the statute until the day before trial, and therefore Dinosaur Park had no prior notice of the need for expert testimony on reasonable rental value; and (2) as the district court ultimately found, Tello's record keeping was so poor that neither party could have presented evidence of the actual rentals collected by Tello.
In sum, in allowing Tello to amend his answer after trial, the district court decided the case based on an issue that was not intentionally or actually tried and caused substantial prejudice to Dinosaur Park. Hence, the district court abused its discretion in deciding the case based on Tello's untimely assertion of section 38-35-126.
It follows that the district court's judgment must be reversed, as must its order awarding attorney fees to Tello. On remand, the district court should, consistent with the views expressed in this opinion, make additional findings and conclusions consistent with those that neither party has appealed, based solely on the record developed at trial.
The judgment is reversed, the order awarding attorney fees is reversed, and the case is remanded for further proceedings consistent with this opinion.
Chief Judge DAVIDSON and Judge CASEBOLT concur.
