
525 A.2d 623 (1987)
Merle W. CLARKE
v.
Mario DIPIETRO et al.
Supreme Judicial Court of Maine.
Argued January 15, 1987.
Decided May 15, 1987.
*624 Allen J. Hrycay (orally), Reef, Jordan & Hrycay, Portland, for plaintiff.
Roderick R. Rovzar, James D. Poliquin (orally), Norman, Hanson & Detroy, Portland, for defendants.
Before McKUSICK, C.J., and ROBERTS, WATHEN, GLASSMAN, SCOLNIK and CLIFFORD, JJ.
CLIFFORD, Justice.
In this action for specific performance of a contract to convey real estate, the plaintiff, Merle Clarke, appeals a judgment entered by the Superior Court, Cumberland County, in favor of the defendants Mr. and Mrs. Mario DiPietro. Clarke contends that the Superior Court erred by permitting the DiPietros to amend their answer after trial to add the affirmative defense of fraud. We disagree with Clarke and accordingly affirm the judgment.
In early March, 1985, Clarke and Mr. DiPietro had some discussions about selling some property in Portland owned by Mrs. DiPietro. The property in question had a commercial garage and facilities for parking and sale of automobiles. Encouraged by these discussions, Clarke arranged to meet Mrs. DiPietro at her home on March 7, 1985, to talk with her about selling. Clarke filled out and brought with him a preprinted form contract for the sale of real estate. After some discussion, Mrs. DiPietro signed this contract.
Within a week Mr. DiPietro notified Clarke orally and later in writing that Mrs. DiPietro had changed her mind and was repudiating the contract. Mr. DiPietro also attempted to return $1,000 in earnest money Clarke had given Mrs. DiPietro at the March 7 meeting. Clarke refused to accept the repudiation and would not take back the earnest money.
On July 5, 1985, Clarke filed a complaint alleging breach of a contract to sell real estate and requesting specific performance and incidental damages. The DiPietros' answer raised four affirmative defenses, none of which alleged fraud. One month before trial, the DiPietros amended their answer to add the additional affirmative defense that the contract did not satisfy the statute of frauds.
The suit was tried on July 31, 1986. In accordance with the parties' stipulation at the beginning of the trial that ambiguity and completeness of the contract were material issues, the court admitted de bene the DiPietros' testimony about the negotiations that had occurred during the March 7 meeting. The DiPietros testified that at the meeting Mrs. DiPietro had expressed reluctance to sell. The property was the main source of Mr. DiPietro's livelihood and she had misgivings about selling the property. According to the DiPietros, Clarke promised Mrs. DiPietro that, if she signed the contract he had prepared, she could unilaterally repudiate it within 30 days. Mrs. DiPietro then signed the contract, relying on this promise. In his testimony, Clarke flatly denied having made the promise. Both parties examined and cross-examined on these points.
At the conclusion of the non-jury trial the court called counsel into chambers and suggested that the DiPietros move to amend their answer by adding the affirmative defense of fraud. The DiPietros did so, over Clarke's objection, and the court granted the motion and entered judgment for the DiPietros.
*625 The court specifically found that Clarke had promised Mrs. DiPietro that she would have 30 days to tear up the contract if she would sign and that Mrs. DiPietro signed only because she received that promise. The court considered this "actual fraud at worst and constructive fraud at best" and declared that in the circumstances specific performance was not an appropriate equitable remedy. The court concluded that fraud had vitiated the contract and granted rescission. Clarke seasonably appealed.[1]

I.
Clarke first contends that the evidence on which the court based its finding of fraud was inadmissible by virtue of the parol evidence rule. We disagree. The parol evidence rule is a rule of substantive law, not an evidentiary rule. Interstate Indus. Uniform Rental Service, Inc. v. F.R. Lepage Bakery, Inc., 413 A.2d 516, 519, 521 (Me.1980). It operates to exclude from judicial consideration extrinsic evidence offered to vary, add to, or contradict the terms of an integrated written agreement. Waxler v. Waxler, 458 A.2d 1219, 1224 (Me.1983); Astor v. Boulos Co., Inc., 451 A.2d 903, 905 (Me.1982). Parol evidence of the parties' negotiations and mutual understandings was admissible on the preliminary question whether the written agreement was completely or just partially integrated. See Harriman v. Maddocks, 518 A.2d 1027, 1030 (Me.1986); Waxler, 458 A.2d at 1224; Connell v. Aetna Life & Casualty Co., 436 A.2d 408, 412 (Me.1981).

II.
Clarke further contends that the DiPietros effectively waived fraud as an affirmative defense by failing to amend their answer in a timely manner. The Maine Rules of Civil Procedure require that affirmative defenses be pleaded. M.R.Civ.P. 8(c) & 12(b). Fraud is an affirmative defense in an action on a contract, and if it is not raised by sufficient pleading at the trial level, it is ordinarily deemed waived. Inniss v. Methot Buick-Opel, Inc., 506 A.2d 212, 218 (Me.1986); Blue Spruce Co. v. Parent, 365 A.2d 797, 801 (Me.1976); M.R. Civ.P. 12(b).
Nevertheless, the fact that an affirmative defense has not been formally pleaded is immaterial if the issue was tried by express or implied consent. See DiBiase v. Universal Design & Builders, Inc., 473 A.2d 875, 877-78 (Me.1984); Conary v. Perkins, 464 A.2d 972, 975-76 (Me.1983); Maine Mortgage Co. v. Tonge, 448 A.2d 899, 901-02 (Me.1982); Boulet v. Beals, 158 Me. 53, 58, 177 A.2d 665, 667 (1962). Rule 15(b) of the Maine Rules of Civil Procedure provides that "[w]hen issues not raised by the pleadings are tried by express or implied consent of the parties, they shall be treated ... as if they had been raised in the pleadings." M.R.Civ.P. 15(b). In such a case, any party may then amend the pleadings, even after judgment, to cause them to conform to the evidence. Id. We conclude that the issue of fraud was tried by implied consent.
We have held that an unpleaded affirmative defense will be viable only where it clearly appears from the record that the defense was in fact tried by the implied consent of the parties. Blue Spruce Co., 365 A.2d at 802. Where, as here, both parties developed the factual basis for the unpleaded affirmative defense, the principal issue is whether Clarke was prejudiced by the post-trial amendment. See 3 J. Moore, Moore's Federal Practice ¶ 15.13[2] at 15-131 (2d ed. 1985). Cf. Geo. Byers Sons, Inc. v. East Europe Import Export, Inc., 488 F.Supp. 574, 585 (D.Md.1980). The test for prejudice is whether he had a fair opportunity to meet the evidence and whether he could offer any additional evidence in rebuttal if the case were retried. See Wilson v. Strong, 474 A.2d 176, 179 (Me.1984); Bouchard v. Jacques, 370 A.2d 680, 682 (Me.1977). In the trial court *626 Clarke argued only that the amendment was untimely and that the defense of fraud should therefore be treated as waived.
In his reply brief on appeal to this court Clarke contends that, had fraud been pleaded in the answer, he "would have had the opportunity to take discovery on the issue of [fraud] which would have led to additional testimony at trial." Nevertheless, all of the principals to the transaction testified. The facts are simple and straightforward. Both parties examined on these points. At no time has Clarke contended that he could call other witnesses to rebut the allegation of fraud.[2] We are persuaded on this record that the facts of Clarke's promise and its effect as inducement were fully litigated.
The dominant policy of the Maine Rules of Civil Procedure is to promote substantial justice. M.R.Civ.P. 1. Moreover, it is the obligation of a court sitting in equity to satisfy itself that it will not "be lending its assistance to the carrying out of an unjust and inequitable arrangement." Fortin v. Wilensky, 142 Me. 372, 379, 53 A.2d 266, 269 (Me.1947); see also Dunham v. Hogan, 143 Me. 142, 144, 56 A.2d 550, 551 (1948); J.B. Brown & Sons v. Boston & Maine R.R., 106 Me. 248, 255, 76 A. 692, 695 (1909); Mansfield v. Sherman, 81 Me. 365, 367-68, 17 A. 300 (1889); Snell v. Mitchell, 65 Me. 48, 50-51 (1876). Accordingly, once fully apprised by the parties of all the circumstances underlying the transaction, the court was entitled both to draw the parties' attention to an essential issue and to fashion appropriate relief. See, e.g., DiBiase, 473 A.2d at 877; see M.R.Civ.P. 54(c); see also George Cohen Sons & Co. v. Koch, 376 F.2d 629, 632-33 (1st Cir.1967).
We conclude that the issue of fraud was tried by implied consent and that therefore the court did not err in permitting the DiPietros to amend. We cannot conclude on these facts that the court clearly erred in finding fraud. See Harriman, 518 A.2d at 1029. Having found fraud, the court properly ordered the contract rescinded.
The entry is:
Judgment affirmed.
All concurring.
NOTES
[1]  The DiPietros have cross-appealed arguing that because the contract used by Clarke was a preprinted form, on which the preprinted language of acceptance was crossed out, the contract was incomplete and therefore barred from enforcement by the statute of frauds, 33 M.R. S.A. § 51(4) (1978). Having determined that the contract was properly rescinded by the court, we have no occasion to decide the issue raised in the cross appeal.
[2]  At oral argument Clarke contended that had he opportunity for further discovery, he could have possibly produced impeaching evidence that the DiPietros were entertaining other offers to buy and that they therefore had a motive to assert the 30-day back-out agreement. All of the impeaching evidence was already in Clarke's possession before trial, nevertheless, and we see no reason why he could not have offered it at trial. Moreover, at the chambers conference following the trial Clarke declined the court's offer to hear additional testimony.
