
874 P.2d 742 (1994)
IDAHO RESOURCES, INC., An Idaho Corporation, a/k/a Nevada-Idaho Resources, Inc.; Fireman's Fund Insurance Company, a California Corporation, Appellants/Cross-Respondents,
v.
FREEPORT-McMORAN GOLD COMPANY, a Delaware Corporation, as Agent for the Freeport-FMC Jerritt Canyon Joint Venture, a Joint Venture Between Freeport-McMoran Gold Company and FMC Jerritt Canyon Corporation, a Delaware Corporation, Respondent/Cross-Appellant.
No. 23387.
Supreme Court of Nevada.
May 19, 1994.
*743 Wilson & Barrows, Elko; Aherin & Rice, Lewiston, ID, for appellants/cross-respondents.
Bible, Hoy, Trachok, Wadhams & Zive and Mark S. Sertic, Reno, for respondent/cross-appellant.

OPINION
PER CURIAM:
Respondent/cross-appellant Freeport-McMoran Gold Company (Freeport), a mining company, contracted with appellant/cross-respondent Idaho Resources, Inc. (Idaho Resources) to process ore extracted by Freeport at Freeport's mine. When Idaho Resources failed to process the quantity of ore required by the contract, Freeport terminated the contract. Freeport brought suit against Idaho Resources, averring, inter alia, that Idaho Resources breached the contract by failing to process the quantity of ore called for in the contract. Idaho Resources counterclaimed against Freeport, alleging that Freeport breached its contract obligations to Idaho Resources by failing to deliver to Idaho Resources sufficient quantities of ore to be processed.
After a bench trial, the district court found that Idaho Resources breached the contract and that Freeport did not breach the contract. Since the record contains substantial evidence to support this conclusion of the district court, it must be upheld. See Hermann Trust v. Varco-Pruden Buildings, 106 Nev. 564, 566, 796 P.2d 590, 591-92 (1990); Pandelis Constr. Co. v. Jones-Viking Assoc., 103 Nev. 129, 130, 734 P.2d 1236, 1237 (1987). The district court, however, also concluded that Freeport could not recover damages on Idaho Resources' breach because Freeport was estopped from terminating the contract for cause. We conclude that the district court's application of the doctrine of equitable estoppel in the instant case constituted error.
Equitable estoppel is an affirmative defense and must be affirmatively pleaded. NRCP 8(c). If an affirmative defense is not properly asserted, or tried by consent, it is waived. Second Baptist Ch. v. First Nat'l Bank, 89 Nev. 217, 220, 510 P.2d 630, 632 (1973). Idaho Resources never raised the issue of estoppel in any pleadings or any other papers filed with the court, including its answer, pretrial statement, or post-trial brief. The record suggests that the issue of equitable estoppel was never litigated by the parties and was first raised in the judgment itself.
NRCP 54(c) states, "[E]very final judgment shall grant the relief to which the party in whose favor it is rendered is entitled, even if the party has not demanded such relief in his pleadings." Courts in other jurisdictions have construed the identical rule narrowly, however. The Utah Supreme Court stated:
Although Rule 54(c)[ ] permits relief on grounds not pleaded, that rule does not go so far as to authorize the granting of relief on issues neither raised nor tried.
. . . .
It is error to adjudicate issues not raised before or during trial and unsupported by the record. The trial court is not privileged to determine matters outside the issues of the case, and if he does, his findings will have no force or effect. In law or in equity, a judgment must be responsive to the issues framed by the pleadings, and a trial court has no authority to render a decision on issues not presented for determination. Any findings rendered outside the issues are a nullity. A court may not grant judgment for relief which is neither requested by the pleadings nor within the theory on which the case was tried, whether that theory was expressly stated or implied by the proof adduced. Parties may limit the scope of the litigation if they choose, and if an issue is clearly withheld, the court cannot nevertheless adjudicate it and grant corresponding relief.
Combe v. Warren's Family Drive-Inns, Inc., 680 P.2d 733, 735-36 (Utah 1984) (citations omitted). In Evans Products Co. v. West American Ins. Co., 736 F.2d 920 (3d Cir. 1984), the Third Circuit Court of Appeals reversed the district court after the district court went outside the pleadings and arguments at trial to reach its decision, stating:
Fed.R.Civ.P. 54(c) permits relief based on a particular theory of relief only if that *744 theory was squarely presented and litigated by the parties at some stage or other of the proceedings. Put another way, relief may be based on a theory of recovery only if the theory was presented in the pleadings or tried with the express or implied consent of the parties.
. . . .
The theory on which relief was granted to Evans had neither been raised in any of the pleadings nor been litigated with either the express or implicit consent of the parties. West therefore was denied a fair opportunity to defend against the theory.... The relief granted by the district court thus was improperly granted because the theory upon which it was based had not been squarely presented and litigated at any stage of the proceedings and because West thereby had been prejudiced.
Id. at 923-24 (citations omitted). In National Medical Care, Inc. v. Zigelbaum, 18 Mass. App.Ct. 570, 468 N.E.2d 868 (1984), the court stated:
In this case, the record amply demonstrates that the judge's invocation of the doctrine of estoppel was a surprise to all parties.... It is undisputed that the defense of estoppel was not pleaded, that the issue was not raised in the post-trial submissions of the parties, and that no amendment to include the defense was sought. The parties did not focus on the question during the trial....
... We hold simply that where the affirmative defense is not pleaded, where the parties do not at trial join issue on the matter and where the evidence does not show conduct "which is inherently wrongful or which is violative of some fundamental principle of public policy," the judge may not rest his decision on that defense without more.
Id. at 875 (citations omitted). Therefore, we conclude that it was error for the district court to raise an estoppel issue here which had not been either pleaded or litigated by the parties. We have considered all other contentions on appeal and we conclude that they either lack merit or need not be addressed in light of this disposition.
Accordingly, we vacate the judgment of the district court insofar as it estops Freeport from recovering damages on Idaho Resources' breach of contract and remand the matter to the district court for a calculation of damages.
