
169 P.3d 675 (2007)
The TOWN OF CARBONDALE, a Colorado home rule municipal corporation, Petitioner,
v.
GSS PROPERTIES, LLC, a North Carolina limited liability company, Respondent.
No. 05SC749.
Supreme Court of Colorado, En Banc.
October 15, 2007.
*676 Caloia Houpt & Hamilton, P.C., Mark E. Hamilton, Glenwood Springs, Colorado, Jean E. Dubofsky, P.C., Jean E. Dubofsky, Boulder, Colorado, Attorneys for Petitioner.
Walter H. Sargent, P.C., Walter H. Sargent, Colorado Springs, Colorado, Attorney for Respondent.
Colorado Municipal League, Geoffrey T. Wilson, Denver, Colorado, Attorney for Amicus Curiae Colorado Municipal League.
Holme Roberts & Owen, LLP, Colin G. Harris, Boulder, Colorado, Attorney for Amici Curiae Colorado Farm Bureau and Colorado Horsemen's Council, Inc., t/a Colorado Horse Council, Inc.
*677 Justice EID delivered the Opinion of the Court.
Petitioner the Town of Carbondale ("the Town") filed suit against Respondent GSS Properties, LLC ("GSS") concerning GSS's construction activities and use of agricultural chemicals on a tract of land located above the Town's water supply. The Town asserted, inter alia, that its local watershed ordinance prohibited the use of such chemicals. Shortly before trial, GSS moved to amend its answer to state a preemption defense. In particular, GSS asserted an operational conflict between the Town's ordinance and various state statutes. Before the court ruled on GSS's motion to amend, GSS reasserted its operational preemption defense in a motion for partial summary judgment.
The trial court denied GSS's motion to amend, subsequently denied GSS's motion for partial summary judgment, and did not permit consideration of the preemption defense at trial. On appeal, the court of appeals reversed and remanded. See Town of Carbondale v. GSS Props., LLC, 140 P.3d 53, 57 (Colo.App.2005). The court held that, while the trial court was within its discretion to deny the motion to amend, it should have permitted GSS to present the operational preemption defense at trial because GSS had raised the defense in a motion for summary judgment and because there would have been no prejudice to the Town. The court of appeals also raised the question of whether the affirmative defense of operational preemption is in fact waivable.
We now reverse the court of appeals. We hold that the fact that the operational preemption defense was raised in a summary judgment motion did not, in and of itself, constructively amend GSS's answer. We also hold that, because the Town would have been prejudiced by the untimely defense, the trial court did not abuse its discretion in not allowing GSS to proceed with the defense at trial. Finally, we hold that GSS's operational preemption defense is waivable because it does not challenge the subject matter jurisdiction of the trial court. In other words, the trial court would have retained jurisdiction over the lawsuit regardless of whether state law or the Town's ordinance was applied. Because we conclude that GSS's operational preemption defense was not successfully raised, we do not consider the merits of that defense.

I.
In 1999, GSS purchased a fifty-five acre tract of land in Pitkin County, Colorado for the purpose of creating a ranching operation and mountain resort. Shortly thereafter, GSS began construction on the land and instituted a weed management program intended to eradicate noxious weeds and dandelions from the property.
On June 15, 2001, the Town filed suit in Pitkin County District Court, alleging that dirt from the construction site polluted Nettle Creek, the primary source of drinking water for the Town, and that GSS's use of herbicides, fertilizers, and pesticides threatened to cause additional contamination. The Town further alleged that GSS's activities constituted a public nuisance and sought to enjoin these activities under the Town's watershed protection ordinance until GSS implemented "the necessary application and storage controls to prevent contamination of the Town's public water supply."
On June 22, 2001, the Town and GSS entered into a stipulation to resolve the dispute over GSS's use of herbicides and other agricultural chemicals. However, the Town's newly elected board ultimately rejected this compromise in May 2002, stating that its goal was to preclude the use of all agricultural chemicals on the property. The trial court subsequently denied GSS's motion to enforce the stipulation. GSS had filed its answer on September 19, 2001, and the time for amending pleadings under the case management order had lapsed in January 2002. The court had set the case for trial in October 2003.
In June 2003, approximately four months prior to the commencement of trial, GSS filed a motion to amend its answer to state an affirmative defense that the Town's ordinance was preempted by state law. Specifically, GSS asserted that there was an operational conflict between the application of the Town's watershed ordinance and various state statutes. The Town opposed GSS's *678 motion to amend, arguing that the new defense would require significant additional discovery and the retention of additional experts. Before the trial court ruled on this motion and approximately three months before trial, GSS filed a motion for partial summary judgment, reasserting, inter alia, the preemption defense.[1]
On August 4, 2003, the trial court denied GSS's motion to amend, reasoning that the amendment would "substantially change the nature of the trial and put the trial date in jeopardy." GSS then sought relief from this court pursuant to C.A.R. 21, which we denied.
On August 15, 2003, the Town responded to GSS's summary judgment motion. In pertinent part, the Town argued,
The Court ruled in its Order of August 4, 2003 [denying GSS's motion to amend the answer], that these defenses may not be asserted by GSS in this case at this juncture due to the close proximity of trial. . . . As such, the Town does not presently intend to further respond to the preemption issue unless the Court determines that GSS' preemption defenses may go forward.
Two months later, on October 3, 2003, the trial court also denied GSS's motion for partial summary judgment. The order did not specifically address GSS's operational preemption defense, although it "recognize[d] that the issues raised in the [summary judgment] motion may be appropriate to address at mid-trial or other appropriate stages of the trial to the court." Because GSS had asserted a number of issues in its summary judgment motion, the court's order was ambiguous as to whether GSS could argue its operational preemption defense at trial.
The ambiguity, however, was resolved at the outset of trial. When counsel for the Town attempted to discuss the preemption issue in his opening argument, the trial court immediately stopped him, saying,
Excuse me, my order having denied the amendment to the answer and the Supreme Court's refusal to grant an Order of Prohibition puts this issue to rest, does it not? The question is not one of whether the Town has authority. . . . That has been litigated. That is done. That is the law of the case.
Later, the trial court referred to GSS's operational preemption defense as an "interesting and complex question which was not successfully raised in the pleadings in this case and will not be reached by this court." Counsel for GSS did not argue preemption or attempt to introduce evidence on the issue at trial.
Following the bench trial, the court concluded that GSS violated the Town's watershed ordinance and ordered GSS "restrained from storing, mixing, applying or disposing of pesticides, herbicides, fertilizers or chemical compounds on the property in any manner that would pollute the Town's water supply as defined in the ordinance."[2]
GSS appealed and the court of appeals reversed, ruling that GSS should have been permitted to present its operational preemption defense at trial. The court remanded the case to the trial court because it determined that additional fact-finding was necessary before ruling on the merits of GSS's preemption defense. We now reverse the court of appeals.

II.
The court of appeals gave two grounds for its decision. First, the court reasoned that although the trial court was within its discretion to deny GSS's motion to amend its answer to add the operational preemption defense,[3] GSS had constructively *679 amended its answer by raising the defense again in its motion for partial summary judgment. The court also found "no basis" in the record for concluding that such a constructive amendment would prejudice the Town. Second, the court raised the question of whether the affirmative defense of operational preemption could actually be waived. We disagree with both grounds.

A.
The Town contests the court of appeals' holding that GSS's operational preemption defense was incorporated into the answer  despite the trial court's previous denial of GSS's motion to amend  because GSS raised the defense in its motion for partial summary judgment. The court cited two of our decisions to support this proposition: Bebo Construction Co. v. Mattox & O'Brien, P.C., 990 P.2d 78 (Colo.1999), and Cox v. Pearl Investment Co., 168 Colo. 67, 450 P.2d 60 (1969).
Previous court of appeals' opinions have also suggested that an affirmative defense asserted for the first time in a summary judgment motion will be treated as incorporated into the pleadings. See, e.g., Trujillo v. Farmers Ins. Exch., 862 P.2d 962, 965 (Colo. App.1993) ("However, if an affirmative defense is asserted in a motion for summary judgment, it is deemed incorporated into the answer."); Slabey v. Colo. Real Estate Comm'n, 762 P.2d 734, 735 (Colo.App.1988) ("[E]ven if the notice requirement is considered an affirmative defense, it may nevertheless be raised by motion for summary judgment. . . ."); Mountain Gravel & Constr. Co. v. City of Cortez, 721 P.2d 698, 700 (Colo. App.1986) ("[E]ven if [the notice requirement] is considered an affirmative defense, by its inclusion in the city's summary judgment motion it is deemed as being incorporated in the city's answer. . . ."); Comstock v. Collier, 694 P.2d 1282, 1284 (Colo.App.1984) ("An affirmative defense asserted in a motion for summary judgment is treated as being incorporated into the answer."). We believe that the rule articulated by the court of appeals in this and other decisions is overbroad and not in line with our holdings in Bebo and Cox.
In Bebo, we noted that "in some instances, an affirmative defense asserted for the first time in a motion for summary judgment will be deemed to be incorporated into the defendant's answer." 990 P.2d at 84 (citing Cox, 168 Colo. at 70, 450 P.2d at 61) (emphasis added). In order to define the "instances" in which an affirmative defense may be raised for the first time in a summary judgment motion, we must look to the context of those cases. In both Bebo and Cox, we allowed defendants to raise affirmative defenses for the first time in summary judgment motions, but we expressly based our decisions on two factors: first, that the plaintiffs did not object to the untimely defenses, and second, that the plaintiffs were not prejudiced by the delay. See Bebo, 990 P.2d at 84; Cox, 168 Colo. at 71, 450 P.2d at 62.
Additionally, it is significant that in both cases, the trial court  hearing no timeliness objection from the opposing party  found the affirmative defense meritorious and granted summary judgment. Bebo, 990 P.2d at 82; Cox, 168 Colo. at 69, 450 P.2d at 61. We concluded that, where the opposing party has made no procedural objection to the untimely raised affirmative defense, and suffered no prejudice from the untimeliness, it has waived any objection it might have had to the fact that the affirmative defense was raised for the first time in a summary judgment motion. Bebo, 990 P.2d at 84 (citing Cox, 168 Colo. at 71, 450 P.2d at 61-62). In other words, an opposing party who fails to object to an untimely affirmative defense and instead chooses to litigate the merits of the *680 defense in a summary judgment proceeding cannot raise a timeliness objection after the trial court has ruled on the summary judgment motion. Rule 15(b) of the Colorado Rules of Civil Procedure supports this result, as it provides that "[w]hen issues not raised by the pleadings are tried by express or implied consent of the parties, they shall be treated in all respects as if they had been raised in the pleadings."
Bebo and Cox do not stand for the proposition adopted by the court of appeals in this case that asserting a defense in a summary judgment motion is, in and of itself, sufficient to amend the pleadings. Such a "rule," as the court of appeals put it, see Town of Carbondale, 140 P.3d at 57, would contravene Rules 8 and 15 of the Colorado Rules of Civil Procedure. Rule 8 requires affirmative defenses to be set forth in the pleadings. C.R.C.P. 8(c). If the time for amending pleadings as a matter of course has expired, an amendment can occur with leave of the court, with written consent of the adverse party, or "[w]hen issues not raised by the pleadings are tried by express or implied consent of the parties." C.R.C.P. 15(a)-(b). The court of appeals' rule attempts to create a fourth way to amend  namely, by raising a defense in a motion for summary judgment and bypassing Rules 8 and 15 altogether. Bebo and Cox cannot be read to allow such circumvention of the rules.
Properly understood, Bebo and Cox do not apply to the circumstances of this case. First, unlike the situation presented by those cases, the opposing party  here, the Town  made a timeliness objection to the newly raised affirmative defense at every opportunity. The Town initially objected to GSS's motion to amend on the ground that it would require significant additional discovery and the retention of additional experts. The Town again raised its objection in its response to GSS's motion for partial summary judgment, arguing that GSS had waived its operational preemption defense and stating that it would not address the merits of the preemption defense because the trial court's denial of GSS's motion to amend barred GSS from raising it. Thus, in no way can it be said that the Town consented to the amendment of the pleadings.
Second, unlike the plaintiffs in Bebo and Cox, the Town would have been prejudiced if GSS had been allowed to proceed with its operational preemption defense. To determine whether an operational conflict exists, a trial court must determine whether the effect of the local ordinance materially impedes or destroys the state interest. Bd. of County Comm'rs v. Bowen/Edwards Assocs., 830 P.2d 1045, 1059 (Colo.1992). The court must engage in a fact-intensive inquiry requiring determination "on an ad-hoc basis under a fully developed evidentiary record." Id. at 1060. That record did not exist at the time GSS filed its motion to amend the answer, four months before trial and seventeen months after the time for amending pleadings had passed. As the trial court observed, permitting GSS to proceed with its operational preemption defense would "substantially change the nature of the trial." Indeed, had GSS been allowed to proceed with its operational preemption defense, the Town would have suffered prejudice because it would have had to conduct substantial additional discovery and expert preparation in order to respond to that defense. See Polk v. Denver Dist. Court, 849 P.2d 23, 26 (Colo. 1993) (upholding the trial court's denial of a motion to amend the pleadings on the ground, inter alia, that the opposing party would be prejudiced by having to perform "additional and unanticipated discovery"). The need for additional discovery is evidenced by the fact that the court of appeals had to remand this case for further factual findings regarding the preemption issue.
Finally, we note that, unlike in Bebo and Cox, the trial court here did not reach the merits of GSS's preemption defense. While the trial court's summary judgment order was ambiguous as to whether preemption was one of the issues it considered appropriate to re-address at trial, the court cleared up this ambiguity when it referred to GSS's preemption defense as an "interesting and complex question which was not successfully raised in the pleadings in this case and will not be reached by this court." In short, none of the factors important to our decisions in *681 Bebo and Cox  i.e., no timeliness objection, no prejudice, and a ruling on the merits  is present here.
If the opposing party objects to an untimely defense, as occurred in this case, the trial court has discretion to disregard the objection and allow amendment of the pleadings. See C.R.C.P. 15(a). However, prejudice to the opposing party is a reason to deny amendment. Polk, 849 P.2d at 25; see also Bebo, 990 P.2d at 84 ("Additionally, as in Cox, Bebo was not prejudiced by the late assertion of the affirmative defense."). We review the trial court's decision for abuse of discretion. See Polk, 849 P.2d at 25. We conclude that the trial court did not abuse its discretion in prohibiting GSS from presenting its operational preemption defense at trial because, as noted above, the late amendment would have prejudiced the Town.[4]
If a defense is not raised in the answer or through a successful amendment of the answer, it is waived. See Duke v. Pickett, 168 Colo. 215, 218, 451 P.2d 288, 290 (1969) (holding that, under C.R.C.P. 8(c), a defendant "waives all defenses and objections which he does not present in his answer"). GSS did not raise the operational preemption defense in the answer, nor did the trial court abuse its discretion in prohibiting GSS from presenting its operational preemption defense at trial. Therefore, the defense was waived, and we need not consider its merits.

B.
In addition to its reliance on Bebo and Cox, the court of appeals stated that the "application of the rule allowing affirmative defenses to be raised for the first time in a summary judgment motion is particularly appropriate in cases where, as here, the defense is preemption." Town of Carbondale, 140 P.3d at 57 (citing, inter alia, Halprin v. Equitable Life Assurance Soc'y, 267 F.Supp.2d 1030 (D.Colo.2003)) (emphasis added). The court's citation to the Halprin case is accompanied by a parenthetical stating that the Halprin court "not[ed][an] absence of authority for [the] proposition that a preemption defense premised upon statutory application can be waived." Through its citation to Halprin and the accompanying parenthetical, the court of appeals raised the possibility that GSS could not waive its preemption defense, regardless of whether the defense was timely raised. We do not believe that possibility exists in this case.
As noted above, affirmative defenses must be timely pleaded, and failure to do so results in waiver. See C.R.C.P. 8(c); Duke, 168 Colo. at 218, 451 P.2d at 290. A challenge to the trial court's subject matter jurisdiction, on the other hand, cannot be waived and may be raised at any stage of the proceedings. Triebelhorn v. Turzanski, 149 Colo. 558, 561, 370 P.2d 757, 759 (1962) ("[T]he defense of lack of jurisdiction over the subject matter can be raised at any time, even for the first time in this court."); see also Indus. Comm'n v. Plains Util. Co., 127 Colo. 506, 515, 259 P.2d 282, 287 (1953) (stating that defense of lack of subject matter jurisdiction "may be properly presented in this court for the first time"). Thus, an affirmative defense that challenges the subject matter jurisdiction of the trial court can be raised at any time.[5]
*682 We have never considered whether preemption is a jurisdictional  and therefore a non-waivable  defense. Courts considering the matter have held that the waivability of a preemption defense depends entirely on the nature of the alleged preemption. If, as in most cases, the alleged preemption would simply alter the applicable substantive law governing the case, then preemption is waivable. See, e.g., Saks v. Franklin Covey Co., 316 F.3d 337, 349 (2d Cir.2003) (ERISA preemption); Sweeney v. Westvaco Co., 926 F.2d 29, 40 (1st Cir.1991), cert. denied, 502 U.S. 899, 112 S.Ct. 274, 116 L.Ed.2d 226 (1991) (Labor Management Relations Act preemption); Dueringer v. Gen. Am. Life Ins. Co., 842 F.2d 127, 130 (5th Cir.1988) (ERISA preemption); Gilchrist v. Jim Slemons Imports, Inc., 803 F.2d 1488, 1497 (9th Cir.1986) (ERISA and California Fair Employment and Housing Act preemption). Other courts have summarized the rule by stating that where preemption changes only the law to be applied, rather than the forum applying it, preemption is an affirmative defense which will be waived unless timely raised. See, e.g., Haudrich v. Howmedica, Inc., 169 Ill.2d 525, 215 Ill.Dec. 108, 662 N.E.2d 1248, 1254-55 (1996); Gorman v. Life Ins. Co. of N. Am., 811 S.W.2d 542, 545-46 (Tex.1991).
Conversely, if preemption "affects the choice of forum rather than the choice of law," then preemption is akin to a jurisdictional challenge and therefore is not waivable. Gorman, 811 S.W.2d at 545 (citing, inter alia, Int'l Longshoremen's Ass'n v. Davis, 476 U.S. 380, 106 S.Ct. 1904, 90 L.Ed.2d 389 (1986)) (emphasis added). Thus, the United States Supreme Court in International Longshoremen's Association held that preemption was not waivable because the federal statute in question preempted state law and provided that federal courts were the exclusive fora for litigating claims under the statute. 476 U.S. at 388, 106 S.Ct. 1904; see also Haudrich, 215 Ill.Dec. 108, 662 N.E.2d at 1254 (applying the International Longshoremen's Association distinction between preemption affecting choice of forum and preemption affecting choice of law).
This distinction between preemption based on choice of law and preemption based on choice of forum is consistent with the general distinction between waivable and non-waivable defenses recognized by Colorado law. Compare Triebelhorn, 149 Colo. at 561, 370 P.2d at 759 (explaining that "the defense of lack of jurisdiction over the subject matter can be raised at any time"), with Duke, 168 Colo. at 218, 451 P.2d at 291 (holding that affirmative defense of fraud was waived because it was not timely asserted). Because a preemption defense based on choice of law is directed to the substance of the applicable law, not to the appropriateness of the judicial forum, we hold that such a preemption defense is waivable if it is not timely raised.
Having adopted this distinction, we conclude that GSS's preemption defense is waivable because it concerns the choice of law to be applied by the trial court, not whether the trial court had jurisdiction to hear the parties' dispute. GSS does not argue that the trial court was an improper forum for its defense, only that the substance of the Town's ordinance was preempted by state statute. This is a preemption defense based on choice of law. Consequently, GSS's defense is waivable and, as noted above, was in fact waived in this case.
We recognize that preemption is a somewhat unique affirmative defense because it is oftentimes a private litigant like GSS, not the state itself, that seeks to enforce state law. Similarly, we note that in cases involving express or implied preemption, there will be little or no prejudice to the opposing party from an amendment to the answer to add an untimely preemption defense because, unlike operational preemption, those forms of preemption are primarily matters of statutory interpretation. See Bowen/Edwards Assocs., 830 P.2d at 1056-59 (discussing the three types of preemption); see also Halprin, 267 F.Supp.2d at 1040 (noting that consideration of the defendant's untimely ERISA preemption defense was simply a matter of a "statute's application"). These considerations do not make the defense unwaivable, however, but instead go to whether a trial court should, in its discretion, permit the defendant to go forward with an untimely preemption defense.
*683 Finally, we recognize that preemption involving federal law may raise a separate set of issues, including, for example, the application of the federal Supremacy Clause. These issues, however, are not present in the case at bar.

III.
We hold that the fact that GSS raised the operational preemption defense in a summary judgment motion did not, in and of itself, constructively amend GSS's answer. We also hold that, because the Town would have been prejudiced by the untimely defense, the trial court did not abuse its discretion in not allowing GSS to proceed with the defense at trial. Finally, we hold that GSS's operational preemption defense is waivable because it does not challenge the subject matter jurisdiction of the trial court. Accordingly, the judgment of the court of appeals is reversed, and the trial court's judgment and order are reinstated.
NOTES
[1]  GSS also argued that (1) the water court had exclusive jurisdiction over certain claims alleged by the Town, (2) the Town failed to state a claim on which relief could be granted because the Town did not allege contamination of the water source, negligent application of the chemicals, or other violation of the water protection ordinance, and (3) the Town's claims of erosion were moot.
[2]  The trial court also found GSS negligent in causing erosion that contaminated the Town's water supply and awarded damages to the Town in the amount of $8,389. However, GSS did not appeal that portion of the trial court's judgment.
[3]  Preemption of a local ordinance by state law can take one of three forms. The first two arise when the state legislature, either expressly or impliedly, demonstrates its intent to occupy a given field. As their names suggest, express preemption occurs where the statute's express language demonstrates this intent, and implied preemption occurs where the legislative intent is implied "by reason of a dominant state interest." Bd. of County Comm'rs v. Bowen/Edwards Assocs., 830 P.2d 1045, 1056-57 (Colo.1992); see also Brubaker v. Bd. of County Comm'rs, 652 P.2d 1050, 1055 (Colo.1982) (discussing federal-law preemption). With the third type of preemption, known as operational preemption, a local law is totally or partially preempted where its operational effect conflicts with the application of state law  that is, "where the effectuation of a local interest would materially impede or destroy the state interest." Bowen/Edwards Assocs., 830 P.2d at 1059.
[4]  GSS offers a number of reasons for why it did not raise its operational preemption defense earlier in the proceedings, including (1) the complaint did not allege that GSS's use of chemicals on the property violated the local watershed ordinance, (2) the Town only later argued for a total prohibition of chemicals on the property, and (3) the Town repeatedly represented to the trial court that settlement remained a realistic possibility. GSS's arguments are unavailing. First, the complaint was clearly premised on the local watershed ordinance: It recited the language of the ordinance, particularly highlighting the sections that protected against the introduction of pollutants or contaminants into Nettle Creek. Second, the complaint pursued an injunction to "restrain[ ] the use . . . of chemical herbicides or pesticides" unless GSS implemented the necessary safeguards to prevent contamination and the Town approved those safeguards. This conditional language served as fair warning to GSS that the Town might find no safeguard safe enough. Finally, the possibility of settlement does not excuse insufficient pleadings.
[5]  A party's ability to raise the defense of lack of subject matter jurisdiction is not completely unbounded. In particular, the doctrine of issue preclusion prevents a party from raising the defense in a collateral attack against a final judgment. In re Water Rights of Elk Dance Colo., LLC, 139 P.3d 660, 662 (Colo.2006).
