
115 N.J. 451 (1989)
559 A.2d 400
JAMES CULVER AND LORETTA CULVER, PLAINTIFFS-RESPONDENTS,
v.
INSURANCE COMPANY OF NORTH AMERICA, DEFENDANT-APPELLANT.
The Supreme Court of New Jersey.
Argued November 7, 1988.
Decided June 15, 1989.
*452 Stanley W. Kallmann argued the cause for defendant-appellant (Gennet and Kallman, attorneys; Mark L. Antin, on the brief).
Glenn A. Bergenfield argued the cause for plaintiffs-respondents (Michael F. Chazkel, attorney).
The opinion of the Court was delivered by HANDLER, J.
This appeal arises from a dispute between an insurance carrier and its insureds over subrogation rights. The insured suffered a fire loss that exceeded the coverage of the insurance policy. After payment of the policy limits for the fire loss, the insurer brought a subrogation action against third-party tortfeasors. The case settled, effectively ending the participation of the third-party tortfeasors in the litigation. There followed, however, a contested motion between Insurance Company of North America (INA) and the Culvers, the insurer and insureds, respectively, involving the validity and enforceability of the separate subrogation agreement that had been entered into between these parties. The trial court order determined the motion effectively enforcing the agreement by ordering the disbursement of the settlement proceeds in accordance with its terms.
The insureds then brought a separate action to set aside the judgment enforcing the subrogation agreement and to obtain a more favorable distribution of the subrogation proceeds. The critical issue in this appeal is whether the doctrine of res judicata is a bar to that action. The trial court applied the doctrine and dismissed the complaint. The Appellate Division reversed, determining that equitable considerations, not contract principles, were determinative of the subrogation claims and justified the rejection of the doctrine of res judicata. We conclude that the Appellate Division's analysis of the subrogation interests did not obviate the application of the doctrine of res judicata as a bar to this action, and reverse its judgment.


*453 I.
The record reveals that in November 1981, the Culvers, insureds under a homeowners insurance policy issued by defendant, INA, suffered a fire loss estimated at $185,000. The Culvers submitted a claim to INA, which after investigation of the cause of the loss and extent of the damage, paid the policy limit of $83,373.12. Thereafter, INA instituted a subrogation action against the tortfeasors believed to have caused the fire. The Culvers, claiming that they were under-insured, obtained separate counsel. Eventually, the Culvers and INA entered into an agreement whereby they would proceed jointly against the tortfeasors. Based on an analysis of the provable amount of the Culvers' uninsured loss, the parties agreed to share any recovery 80% for INA and 20% for the Culvers. They also agreed that INA would bear all costs of litigation and be entitled to legal fees.
The parties allegedly responsible for the fire were General Electric Company, the manufacturer of the Culvers' gas stove, and Better Living Department Stores, Inc., the seller and installer of the stove. INA commenced its subrogation action against both parties in plaintiffs' name. INA controlled that litigation in all respects, although plaintiffs had their own counsel with whom they and INA consulted from time to time.
The trial court bifurcated the issues of liability and damages in the subrogation suit. During the liability trial, INA reached a settlement with General Electric, releasing it for the sum of $25,000. At the conclusion of the trial, the jury reached a liability verdict assessing 100% negligence against Better Living. On the day the damages trial was to begin, Better Living negotiated a settlement in the amount of $135,000 and INA obtained the consent of Mrs. Culver to its acceptance of that settlement offer.
Some time after the date of the settlement with Better Living, INA proffered plaintiffs their share of the settlement proceeds, which totalled $160,000. Based on the 80/20 division *454 the proposed distribution was: $23,583.33 to plaintiffs and $92,000 plus $44,416.67 for legal fees and costs to INA.
Plaintiffs refused to accept this division and INA moved in the pending subrogation action against the Culvers for an order to enforce the agreement. The Culvers, with the assistance of new counsel, opposed the motion and cross-moved for a different allocation. In support of the cross-motion, Mrs. Culver submitted a certification in which she alleged fraud and breach of fiduciary duty by INA and its counsel. The trial court rejected these defenses and granted INA's motion, entering an order of distribution in accordance with the agreement.[1] In doing so, the trial judge ruled against plaintiffs' motion to set aside the subrogation agreement.
Plaintiffs did not appeal this order nor did they file a motion for relief. Instead, approximately four months later, plaintiffs commenced a new action, filing a complaint against INA, alleging, as they had in their cross-motion for distribution in the previous action, that their consent to the subrogation allocation agreement was illegally obtained, that INA made misrepresentations, and that INA breached its fiduciary obligation to them. They sought compensatory damages, punitive damages, attorney's fees, interest, costs and a "just and equitable settlement." INA moved for summary judgment on the grounds that the issues raised in the complaint were res judicata, which the trial court granted. On appeal, the Appellate Division reversed. 221 N.J. Super. 493 (1987). Rejecting the application of res judicata, it determined that the subrogation agreement was not *455 enforceable and that the insureds were entitled to be paid the full extent of their loss from the settlement proceeds. INA filed a petition for certification, which this Court granted. 110 N.J. 305 (1988).

II.
In the earlier subrogation action, the trial court decided INA's motion to disburse the settlement proceeds in terms of whether the subrogation agreement was legally enforceable. It rejected all of plaintiffs' claims of misrepresentation and breach of fiduciary duty as a basis for invalidating the agreement and ordered a distribution of the settlement proceeds in accordance with its terms.
In the current case, the trial court found that the plaintiffs' complaint was inclusive of their earlier claims. It therefore determined that the earlier judgment was res judicata, barring the subsequent action. The Appellate Division, however, ruled that the subrogation agreement between the Culvers and INA was not enforceable. It determined that INA, the subrogating insurer, had "a trust obligation to the insured in respect of the difference between the insurance payment and the insured's actual loss," and INA was therefore obligated to hold from the settlement an amount equal to the uninsured portion of their loss in trust for the Culvers. 221 N.J. Super. at 502. The appellate court concluded that "the [subrogation] agreement," calling for a different result, "appears to be unconscionable, violative of public policy and in abrogation of INA's trust obligation to its insureds." Id. at 504. This conclusion, according to the Appellate Division, obviated the application of the doctrine of res judicata.
The Appellate Division appropriately recognized the importance and uniqueness of the doctrine of subrogation, stressing its equity underpinnings. It has long been appreciated that "[s]ubrogation is a device of equity to compel the ultimate discharge of an obligation by the one who in good conscience *456 ought to pay it [and] * * * to serve the interests of essential justice between the parties." Standard Accident Ins. Co. v. Pellecchia, 15 N.J. 162, 171 (1954) (citations omitted). The doctrine is highly favored in the law. Ibid.
It is important to understand that subrogation rights do not arise spontaneously nor are they free-floating or open-ended. Subrogation rights are created in one of three ways: "(1) an agreement between the insurer and the insured, 44 Am.Jur.2d Insurance § 1820 at 746, (2) a right created by statute, 16 Couch on Insurance 2d § 61:6 at 240 (1966), or (3) a judicial `device of equity to compel the ultimate discharge of an obligation by the one who in good conscience ought to pay it.'" Aetna Ins. Co. v. Gilchrist Brothers, Inc., 85 N.J. 550, 560 (1981). While the doctrine has an equitable foundation, the attitude of courts toward subrogation has been described as "one of allowing complete freedom of contract and trying to determine and enforce the expressed intention of contracting parties." R. Keeton, Insurance Law § 3.10 at 153. Indeed, subrogation "is not applicable where its enforcement would be inconsistent with the terms of a contract or when the contract, either expressly or by implication, forbids its application." Ganger v. Maffett, 8 N.J. 73, 80 (1951).
The analysis of the Appellate Division appears to place emphasis only on the equitable nature of subrogation, discounting the contract basis for its application. Nevertheless, in this case the subrogation rights of INA were established in the insurance policy itself; further, INA and the Culvers negotiated and entered into a supplementary agreement defining their correlative subrogation interests.
The appellate court appropriately turned for guidance initially to equitable principles under the standard subrogation clause of the insurance policy; nevertheless, it failed then to consider the contractual relevance of the specific subrogation agreement. In Providence Washington Ins. Co. v. Hogges, 67 N.J. Super. 475 (App.Div. 1961), the court held that when the *457 insurance policy contained only a general subrogation clause that did not specify how subrogation proceeds would be paid, general equitable principles of subrogation governed. Such subrogation principles, however, could be altered by contract:
Subrogation is an offspring of equity, and its equitable principles apply even when the subrogation is based on contract, except as modified by specific provisions in the contract. Here we have only the general clause quoted. Under such a clause, in case of doubt the interests of the insured come first. In the absence of express terms in the contract to the contrary, he must be made or kept whole before the insurer may recover anything from him or from a third party under its right of subrogation. Against the insured, as well as against third parties, there may be recovery by the insurer (again, subject to the express terms of the contract) "only if the cause is just and enforcement is consonant with reason and justice." [Id. at 482 (emphasis added).]
The Appellate Division in this case, while relying on Providence Washington Ins. Co., indicated that the supplementary contract could be disregarded because it appeared to be "unconscionable" and "violative of public policy." Nevertheless, the court did not suggest that the agreement constitutes a contract of adhesion. See, e.g., Sparks v. St. Paul Ins. Co., 100 N.J. 325, 335 (1985); Allen v. Metropolitan Life Ins. Co., 44 N.J. 294, 305-06 (1965). Nor did it indicate that the terms of the agreement were doubtful or failed to fulfill the reasonable expectations of the insureds. See, e.g., Sparks v. St. Paul Ins. Co., supra, 100 N.J. at 336-38; Bryan Const. Co. Inc. v. Employers' Surplus Lines Ins. Co., 60 N.J. 375, 377-78 (1972).
The Appellate Division apparently believed that a supervening equitable principle, namely, the right of the insured to be made whole, overcomes rights provided by contract. This conclusion, however, does not necessarily follow from the principal rationale behind insurance subrogation, namely, that "the insurer should be reimbursed for his payment to the insured," Standard Accident Ins. Co. v. Pellecchia, supra, 15 N.J. at 171, and is subrogated only to those rights of the insured that are sufficient to reimburse it for the amount of the loss paid. See Restatement of Restitution § 162, comment c (1937).
It may be that the Appellate Division sought to invoke and adapt that rationale in this case. The court thus stated, "just *458 as the insured has a trust obligation to the insurer for any sum he recovers from the tortfeasor in excess of his actual loss, so does the subrogating insurer have a trust obligation to the insured in respect to the difference between the insurance payment and the insured's actual loss." 221 N.J. Super. at 502. It then ruled that the insurer has a duty to pay the insured for its entire loss before it can reimburse itself for any part of the loss that it paid under the policy.[2] Nevertheless, the Appellate Division in reaching this conclusion relied on Providence Washington Ins. Co. v. Hogges, supra, 67 N.J. Super. 475, in which the court allowed the insured to be paid its $50 deductible from the third party award before the insurer could be reimbursed for its insurance payment. But, as earlier noted, Providence *459 Washington expressly recognized that this result could be altered by contract. Id. at 482. The other cases relied on by the Appellate Division, Camden Fire Ins. Ass'n v. Prezioso, 93 N.J. Eq. 318, 320 (Ch.Div. 1922), and Federal Ins. Co. v. Engelhorn, 141 N.J. Eq. 349, 351 (E. & A. 1947), also do not suggest that general subrogation principles calling for similar results cannot be modified by contract.
We are therefore unable to conclude that the Appellate Division correctly decided on the record of this case that a subrogation contract providing for a division of proceeds that favored the insurer was unenforceable, as a matter of law, or that the insured be made whole first from the settlement of a subrogation action, despite a contractual agreement to the contrary. We are, however, satisfied that under either the Appellate Division's theory of subrogation or that of the trial court and the parties, the current action should be barred by the doctrine of res judicata.

III.
The Appellate Division reversed the trial court because it concluded that the subrogation contract did not overcome equitable principles governing subrogation. The Appellate Division only tangentially addressed the trial court's dismissal of the Culvers' claim based on res judicata. It could be inferred from its opinion, however, that the Appellate Division believed either that the issues of breach of fiduciary duty and misrepresentation were never fully addressed in the first lawsuit or, more likely, that under its view of the cause of action these issues were not determinative. Under either approach, we believe that the Appellate Division's rejection of res judicata was incorrect.
The essential issues were clearly implicated, if not fully addressed, in the original subrogation action. Plaintiffs contended that INA misled Mrs. Culver into consenting to the subrogation arrangement and breached a fiduciary obligation; *460 in contrast, defendant denied any misrepresentations or breach of duty.[3] These conflicting contentions were also raised in the earlier action in the contested motion seeking enforcement of the subrogation agreement where Mrs. Culver alleged fraud and breach of fiduciary duty by INA and its counsel. Thus, these issues were presented in both actions.
The doctrine of res judicata "contemplates that when a controversy between parties is once fairly litigated and determined it is no longer open to relitigation." Lubliner v. Board of Alcoholic Beverage Control, 33 N.J. 428, 435 (1960). Where the second action is no more than a repetition of the first, the first lawsuit stands as a barrier to the second. "The rule precludes parties from relitigating substantially the same cause of action." Kram v. Kram, 94 N.J. Super. 539, 551 (Ch.Div.), rev'd on other grounds, 98 N.J. Super. 274 (App.Div. 1967), aff'd, 52 N.J. 545 (1968).
The application of res judicata doctrine requires substantially similar or identical causes of action and issues, parties, and relief sought. Eatough v. Board of Medical Examiners, 191 N.J. Super. 166, 173 (App.Div. 1983); Constant v. Pacific Nat'l Ins. Co., 84 N.J. Super. 211, 216 (App.Div. 1964). In addition, there must be a "final judgment by a court or tribunal of competent jurisdiction." Charlie Brown of Chatham v. Board of Adjustment, 202 N.J. Super. 312, 327 (App.Div. 1985).
In this case there is identity of parties. The relief sought, i.e., a fair distribution of settlement proceeds from the subrogation *461 action, is essentially the same, even though in the second action the claim for damages is expanded to include other forms of monetary relief. Further, the prior action was concluded by a final judgment. The trial court distinctly decided the issue whether the settlement proceeds from the third-party tortfeasors should be distributed according to the separate subrogation agreement entered into between INA and the Culvers. In view of the detailed factual contentions presented by the parties addressed solely to the validity of their agreement, it is not readily inferable, as suggested by the dissent, that the trial court believed that the dispute involved only the validity of the settlement with the third-party tortfeasors. If the court wrongly decided the proper distribution of the settlement proceeds or failed to address the Culvers' fraud and breach of fiduciary duty claims, plaintiffs of course could have sought relief from the trial court or appealed from this final judgment. They did neither. Cf. City of Newark v. North Jersey Water Supply Comm'n, 106 N.J. Super. 88, 98-99 (Ch.Div. 1968) (plaintiff, which lost action to invalidate contract and afterwards found additional evidence to support its position, did not seek post-judgment trial or appellate relief, but brought second action seeking essentially same relief; applying analogous entire controversy doctrine, court ruled that subsequent action was barred), aff'd per curiam, 54 N.J. 258 (1969). Hence, the doctrine of res judicata applies unless the causes of action and essential issues were not substantially the same.
The test for the identity of a cause of action for claim preclusion purposes is not simple. The term "`cause of action' cannot be precisely defined, nor can a simple test be cited for use in determining what constitutes a cause of action for res judicata purposes." Donegal Steel Foundry Co. v. Accurate Prods. Co., 516 F.2d 583, 588 n. 10 (3d Cir.1975). To decide if two causes of action are the same, the court must consider:
(1) whether the acts complained of and the demand for relief are the same (that is, whether the wrong for which redress is sought is the same in both actions) Gissen v. Tackman, 401 F. Supp. 310, 312 (D.N.J. 1975); (2) whether the theory *462 of recovery is the same; (3) whether the witnesses and documents necessary at trial are the same (that is, whether the same evidence necessary to maintain the second action would have been sufficient to support the first) O'Shea v. Chrysler Corporation, 206 F. Supp. 601, 605 (D.N.J. 1962); and (4) whether the material facts alleged are the same. [United States v. Athlone Industries, Inc., 746 F.2d 977, 984 (3d Cir.1984).]
Taking this approach, we can find a high degree of similarity between the two lawsuits. The acts complained of are the same; they involve the conduct of the insurer that constitutes a breach of fiduciary duty, fraud, or misrepresentation sufficient to invalidate the subrogation agreement. Moreover, the material facts encompassing INA's alleged misconduct are identical; virtually the same evidence would be necessary to establish this misconduct in both actions. In addition, a similar demand for relief is presented in each action, namely, the setting aside of the subrogation agreement to obtain a more favorable distribution of subrogation proceeds. Finally, any verdict for plaintiffs in this case would completely overturn the ruling in the first action.
This conclusion is not altered by the Appellate Division's view of the cause of action as one resting on equitable rather than contract principles. The Appellate Division variously characterized the cause of action brought by the Culvers as "unconscionability," or violations of public policy, or breach of a fiduciary duty. Nevertheless, it does not appear that its cause of action would be any different from the earlier action or that the factual issues and evidence would vary materially. For example, in determining the unconscionability of a contract, in addition to inspecting the terms of the contract, the court will "scrutinize `the relations of the parties and all the surrounding circumstances.'" (citations omitted). Rotwein et al. v. General Accident Group & Casualty Co., 103 N.J. Super. 406, 418 (Law Div. 1968). However, this is virtually the same factual inquiry that was presented to the court in the earlier subrogation lawsuit. For purposes of res judicata, we do not believe that the theory of recovery, as viewed by the Appellate Division, *463 is sufficiently different to warrant avoidance of res judicata.
Moreover, in the context of this litigation, any putative differences between the causes of action would not overcome the bar of claim preclusion. The principle of res judicata applies not only to "all matters litigated and determined by such judgment but also as to all relevant issues which could have been presented, but were not." Anselmo v. Hardin, 253 F.2d 165, 168 (3d Cir.1958); see Mazzilli v. Accident and Casualty Ins. Co., 45 N.J. Super. 137, 141 (App.Div. 1957); Bowers v. American Bridge Co., 43 N.J. Super. 48, 66 (App.Div. 1956); see also Angel v. Bullington, 330 U.S. 183, 192-93, 67 S.Ct. 657, 662, 91 L.Ed. 832 (1947) ("if issues that were or could have been dealt with in an earlier litigation are raised anew between the same parties," subsequent litigation is "needless" and will not be tolerated under doctrine of res judicata). Thus, if the issues of "unconscionability" or "violations of public policy" are deemed to be different from the issues of fraud, misrepresentation, and breach of fiduciary duty, they were or could have been raised in the previous lawsuit. The dissent suggests that plaintiffs introduced their claim in the previous lawsuit but were not allowed to litigate it due to the trial court's belief that their claim was solely to invalidate their assent to the settlement of the third-party action. Post at 470. This inference is not likely, however, in view of plaintiffs' detailed factual contentions, which attacked their agreement with INA, not their settlement with the third-party tortfeasor. Moreover, regardless of the adequacy or soundness of its determination, the trial court effectively and specifically concluded the issues presented by plaintiffs' claim attacking their agreement through its denial and dismissal of their cross-motion for distribution.
In addition, the entire controversy doctrine requires that all issues of a single dispute between the parties must be completely determined in one action. Rule 4:27-1 provides that "[e]ach party to an action shall assert therein all claims which he may have against any other party thereto insofar as may be required *464 by application of the entire controversy doctrine." As the Court stated in Applestein v. United Board & Carton Corp., 35 N.J. 343, 356 (1961), "a defendant must assert all matters which will defeat a claim against him and a plaintiff must seek complete relief for vindication of the wrong he charges." This doctrine attempts to avoid the delay, waste and expense of fragmented litigation. See R. 4:5-4 (pleadings seeking to present claims sufficient to constitute an avoidance must set forth specific supporting facts; failure to raise such claims constitutes a waiver); Kress v. Kress, 1 N.J. 257 (1949); M. Schnitzer and J. Wildstein, N.J. Rules Services, 4:8-3 § 4 at AIV-154, 156 (1954-1967 edition). To this extent, the entire controversy doctrine is wholly consistent with the doctrine of res judicata. Lubliner v. Board of Alcoholic Beverage Control, supra, 33 N.J. at 435. See City of Newark v. North Jersey Water Supply Comm'n, supra, 106 N.J. Super. 88, aff'd per curiam, 54 N.J. 258. Thus, any new claims involving the subrogation agreement should have been raised in the subrogation lawsuit because that decision determined the entire controversy between the parties.
To characterize the claims brought in the subsequent lawsuit as "equitable," and those in the earlier action as "legal" in no way displaces the bar of res judicata or the entire controversy doctrine. See Massari v. Einsiedler, 6 N.J. 303, 313 (1951). Thus, whether based on breach of fiduciary duty and misrepresentation, or, as characterized by the Appellate Division, on unconscionability and violations of public policy, the insureds' claims are controlled by the principles of res judicata, as well as the companion entire controversy doctrine.

IV.
We conclude that the earlier action and final judgment constitute a bar to any relitigation of the matters in dispute, and that bar applies to the current action.
Accordingly, the judgment below is reversed.
*465 STEIN, J., dissenting.
In this case plaintiffs allege that their insurance carrier fraudulently induced them to enter into an agreement that divided the proceeds of a subrogation claim in a manner grossly disproportionate to the interests of the parties. The Appellate Division set aside the agreement, concluding that it was manifestly inequitable, and in derogation of settled principles of subrogation law. We granted certification and now reverse, holding that the plaintiffs' cause of action is barred by res judicata. I disagree with the majority's application of res judicata to bar a cause of action that the trial court in the subrogation case adamantly refused to entertain because it incorrectly believed plaintiffs' claim was subsumed by the settlement of the subrogation action. I therefore dissent.

I.
The Culvers, homeowners and plaintiffs in this case, suffered a fire loss estimated at $185,000. They submitted a claim to their insurer, INA, which subsequently paid to them the policy limit of $83,373.12. Thereafter, INA instituted a subrogation action, in the Culvers' name, against the alleged tortfeasors, General Electric Company (General Electric), manufacturer of the Culvers' gas stove, and Better Living Department Stores, Inc. (Better Living), seller and installer of the stove. INA largely controlled that litigation.
The Culvers, after obtaining separate counsel, entered into an agreement with INA to proceed jointly against the tortfeasors. The parties also agreed to share any recovery obtained from either or both of the tortfeasors, in the proportion of eighty percent for INA and twenty percent for the Culvers.
The trial court bifurcated the issues of liability and damages in the subrogation action. In the liability phase, INA settled its claims with General Electric for $25,000, and the jury determined that Better Living was solely responsible for plaintiffs' *466 loss. Before the trial on damages began, INA settled with Better Living for $135,000.
In accordance with its agreement with the Culvers, INA proferred plaintiffs $23,583.33, which constituted twenty percent of the settlement proceeds, leaving INA with $92,000, or eighty percent of the proceeds, as well as $44,416.67 for legal fees and costs. Thus, the Culvers would recover approximately half of their alleged loss, while INA would recover almost $10,000 more than the amount it paid the insured, excluding legal fees.
INA moved in the pending subrogation action for an order directing disbursement pursuant to the agreement. The Culvers opposed the motion, based on a certification in which Mrs. Culver alleged fraud and breach of fiduciary duty by INA and its counsel. Specifically, she alleged that she had signed the agreement only because INA represented that she would not be entitled to any money from the subrogation action until INA had been reimbursed for its payment to the Culvers, and received interest at the rate of twelve percent.
The trial court refused to permit the Culvers to attack the subrogation agreement, apparently on the ground that Mrs. Culver had testified in open court that the terms of the settlement with the third-party tortfeasors was acceptable to her.
THE COURT: [S]he [Mrs. Culver] came into my courtroom and she testified in my courtroom and she agreed to this settlement. And the settlement will stand, and there will be a payout by Mr. Psak [attorney retained by INA]. We can't relitigate cases. I am convinced that this woman's rights were completely protected by Mr. Psak, and that she was given every opportunity to communicate with Mr. Kropf [the Culvers' attorney], and that she represented to him that she did communicate with Mr. Kropf. And who she communicated with is irrelevant.
MR. BERGENFIELD: Judge, if you have already ruled.
THE COURT: I have already ruled.
MR. BERGENFIELD: Thank you, your Honor.
When plaintiffs filed their complaint in the present action, the trial court dismissed the complaint on the basis of res judicata. The trial judge, who had presided in the subrogation action, *467 again based his decision on the fact that Mrs. Culver had consented in open court to the settlement with the third-party tortfeasors:
THE COURT: You understand, Mr. Bergenfield, great many hours were spent by counsel in the original case in settlement of this case. For some reason more than in most. The Court played little or no part in that and certainly the Court as, I recall it, exercised very little pressure on either attorney in this matter. The Court was also aware at all times that there was a dual claim and most of the conferencing was done between Mr. Psak, who is the nominal attorney for Mrs. Culver because he was retained by I.N.A., and her in the corridor of the courthouse in plain view. I saw them myself out there. There was another attorney whose name escapes me as I sit here right now who represented Mrs. Culver. I don't know whether he ever came in the courthouse but I know that she was in communication with him and as a result she assented to the settlement of this case. And you simply want to relitigate this thing over and over and over again.

* * * * * * * *

Nobody broke this lady's arm to get on that witness stand and say that this case was settled. * * * This is awful.
MR. BERGENFIELD: Judge, I don't disagree with the Court's view that there is something awful about the way this came about. I think one of them, though, Judge, is the question to be litigated in this case. It's not the question that was litigated in the underlying case. The question there was a negligence and I think a products liability suit 
THE COURT: And here, all the claims that you would now make were asserted in that case and would have been asserted in a damage suit. There is no question about that, and she agreed that this was the end of it and that she agreed to a split of the settlement money between herself and I.N.A., period. Now, that's what she agreed to. (Emphasis added.)
The Culvers' attorney pressed his contention that the fraud claim against INA had never been litigated in the prior action, but his arguments were rejected by the court:
MR. BERGENFIELD: Judge, the point I'm trying to make, though, is the question in this case, and the point that the Court is I think making to me about the fact that the, that no one twisted her arm when she took the stand is the question to be litigated in this case. The underlying case was a products case or a negligence case. The question here is the validity of her assent and what the Court is saying was litigated.
THE COURT: She agreed to settle whatever claims she had with I.N.A. And she agreed to take a certain percentage of the money being paid by the defendant in that case as satisfaction of her independent claims. And that's what she did. This is going to relitigate that, whatever those claims may have been.


*468 MR. BERGENFIELD: But that wasn't litigated, Judge, that's my only point.
THE COURT: The Court is granting this motion. (Emphasis added.)
The Appellate Division concluded that the trial court erred in holding that the Culvers' claim was barred by res judicata. It held that the subrogation agreement between the Culvers and INA was unenforceable because it "violated every concept of fair play which underlies the whole doctrine of subrogation." Culver v. Insurance Co. of N. Am., 221 N.J. Super. 493, 503 (1987). While acknowledging that common law subrogation principles may be modified by contract, the court maintained that "since `subrogation is an offspring of equity * * * its equitable principles apply even when the subrogation is based on contract, except as modified by specific provisions in the contract.'" Id. at 500 (quoting Providence Washington Ins. Co. v. Hogges, 67 N.J. Super. 475, 482 (App.Div. 1961)). The court further found that "[a]s a matter of equitable principle, the right of subrogation does not arise until the injured party has been made whole." 221 N.J. Super. at 500.
We granted certification, 110 N.J. 305 (1988). The majority opinion in this case acknowledges that the question of the allocation of proceeds in a subrogation action, absent an agreement, is unsettled in New Jersey and susceptible to various approaches. See ante at 458 n. 2 ("The rule adopted by the Appellate Division is just one of five possible rules that can govern what happens if an insurer seeks recovery from a third-party tortfeasor where the insured's total loss has not been repaid in full."). Nevertheless, the majority concludes that plaintiffs are precluded by res judicata from proving their claim that they were misled by INA into signing the agreement.

II.
The preclusionary principles of res judicata and collateral estoppel serve to insulate courts from the relitigation of claims and issues, and to prevent harassment to parties and their privies. See Restatement (Second) of Judgments § 19 comment a (1982) ("The rule that a defendant's judgment acts as a *469 bar to a second action on the same claim is based largely on the ground that fairness to the defendant, and sound judicial administration, require that at some point litigation over the particular controversy come to an end.").
Justice Brennan articulated these basic principles in Bango v. Ward, 12 N.J. 415 (1953):

When a party who is afforded a fair opportunity to litigate a claim or cause of action before a court which has jurisdiction over the parties and the subject matter suffers a final judgment adverse to him on the merits, parties in whose favor the judgment is entered, and their privies, may assert the judgment as a bar in a subsequent action on the same claim or cause of action. The public interest in putting an end to litigation, which underlies the principle of res judicata, as well as the interest of parties requires that the loser in such case shall be denied a second chance to litigate the matters determined by the final judgment. [Id. at 420 (citations omitted) (emphasis added).]
Restatement, supra, § 19, states the general rule of res judicata as follows: "A valid and final personal judgment rendered in favor of the defendant bars another action by the plaintiff on the same claim." The commentary adds:
The prototype case continues to be one in which the merits of the claim are in fact adjudicated against the plaintiff after trial of the substantive issues. [Restatement, supra, § 19 comment a.]
Furthermore, the application of res judicata in a subsequent action between the same parties traditionally has been limited to cases in which those parties were "adverse" to one another in the prior action. See Fishgold v. Sullivan Drydock & Repair Corp., 328 U.S. 275, 291, 66 S.Ct. 1105, 1114, 90 L.Ed. 1230, 1243 (1946) ("A fair application of res judicata bars a party in a second litigation only if that proceeding involves the same issues as the first litigation between the same adverse parties or privies.") (Black, J., dissenting); Pearlman v. Truppo, 10 N.J. Misc. 477, 478 (Sup.Ct. 1932); Desmond v. Kramer, 96 N.J. Super. 96, 100-101 (Union County Ct. 1967); cf. Restatement, supra, § 38 comment a ("The concept of adversarial litigation is that determination of issues is not full and fair unless a party has an opportunity to present proofs and argument specifically directed to the matters in controversy.").
Although the majority bases its decision on the doctrine of res judicata, the related doctrine of collateral estoppel also *470 may be implicated. Collateral estoppel is "that branch of the broader law of res judicata which bars relitigation of any issue which was actually determined in a prior action, generally between the same parties, involving a different claim or cause of action." State v. Gonzalez, 75 N.J. 181, 186 (1977). Collateral estoppel, or "issue preclusion," has been restated as follows:
When an issue of fact or law is actually litigated and determined by a valid and final judgment, and the determination is essential to the judgment, the determination is conclusive in a subsequent action between the parties, whether on the same or a different claim. [Restatement, supra, § 27.]
"A judgment is not conclusive in a subsequent action as to issues which might have been but were not litigated and determined in the prior action." Restatement, supra, § 27 comment e; see also Plainfield v. Public Serv. Elec. and Gas Co., 82 N.J. 245, 257 (1980) (quoting Washington Township v. Gould, 39 N.J. 527, 533 (1963)) ("It is well-settled that where a judgment of a court of competent jurisdiction directly determines a right, question or fact distinctly put in issue, such judgment estops the parties or their privies from thereafter relitigating the same issue in a subsequent proceeding between them, regardless of its nature or form."); New Jersey-Philadelphia, etc. v. New Jersey State Bd. of Higher Educ., 654 F.2d 868, 876 (3d Cir.1981) (collateral estoppel "precludes relitigation only of questions `distinctly put in issue' and `directly determined' adversely to the party against which the estoppel is asserted").

III.
The trial court's disposition of the Culvers' motion in the subrogation action cannot support the application of either res judicata or collateral estoppel. A fair interpretation of the trial court's position is that it believed that the Culvers' challenge to the subrogation agreement necessarily included a challenge to the settlement with the third-party tortfeasors, to which Mrs. Culver assented in open court. As a result, the *471 court refused to entertain the Culvers' claim that the agreement was procured by fraud. In fact, the Appellate Division suggested that the trial court misapprehended the nature of the Culvers' argument in the subrogation suit:
[P]laintiffs' challenge to their agreement with INA was not actually adjudicated in the earlier proceedings. It is our distinct impression that the court's concern with preserving INA's settlement with the two tortfeasors misled it as to the actual grievance plaintiffs were attempting to present. It was not that settlement they were questioning but only their distribution agreement with INA. Had the court so appreciated, we are confident that it would have afforded plaintiffs the opportunity they should then have had of demonstrating their right to be relieved of it. Instead, the court made no inquiry as to either the terms of that agreement or the basis of plaintiffs' challenge to it and made no findings in respect thereof at all. [221 N.J. Super. at 505.]
It is noteworthy that INA and the Culvers were aligned as plaintiffs in the first action against the tortfeasors who allegedly caused the destruction of their home. While the suit was brought in the Culvers' name, the litigation was controlled by INA and its attorneys. The essential "claim" in the first action was the negligence of the third-party tortfeasors; on that issue, of course, the Culvers and INA were not adversarial, a traditional component of the application of either res judicata or collateral estoppel. Although the Culvers and INA were in an adversarial posture in respect of INA's motion to enforce the distribution agreement, it is not at all clear from the record that the trial court distinguished between their adversity concerning distribution of the settlement proceeds and their common interest in negotiating the settlement. Cf. Restatement, supra, § 27 comment e ("Sometimes the party against whom preclusion is asserted is covered by an insurance policy and represented by insurance company counsel in the prior action but not in the subsequent action. In such instances, preclusion with respect to unlitigated issues seems particularly unfair.").
As noted, res judicata and collateral estoppel are intended to conserve judicial resources by barring duplicative litigation of claims or issues already determined. But as the record in this case reveals with such striking clarity, the trial court was under the impression that Mrs. Culver's consent in open court to the terms of the settlement encompassed any latent claims against *472 INA. Thus, when plaintiffs first attempted to assert such a claim, the trial court refused to permit the issue of INA's misrepresentations to be litigated, believing that claim was embraced by plaintiff's assent to the settlement. In that context, the majority's holding applying res judicata appears to overlook the fact that the doctrine's most critical element  the litigation of the underlying issue  simply did not occur in this case.
The result works a harsh inequity on the plaintiffs. More importantly, it subverts the policies underlying the preclusionary rules of res judicata and collateral estoppel. Cf. Restatement, supra, § 27 comment e ("The interests of conserving judicial resources, of maintaining consistency, and of avoiding oppression or harassment of the adverse party are less compelling when the issue on which preclusion is sought has not actually been litigated before."). I would hold that because plaintiffs were not afforded a fair opportunity to litigate their claim in the first action, res judicata should not act as a procedural bar to the present action.
STEIN, J., dissenting.
For affirmance  1.
For reversal  Chief Justice WILENTZ and Justices CLIFFORD, HANDLER, POLLOCK, O'HERN and GARIBALDI-6.
NOTES
[1]  Although the order contained somewhat different figures, plaintiffs contend that the total recovery was divided as follows:



INA:                                         $92,000.00
INA's attorney:                               41,328.33
Culvers' attorney:                             2,671.67
Culvers:                                      24,000.00
                                             __________
TOTAL:                                       160,000.00

[2]  The rule adopted by the Appellate Division is just one of several rules that can govern what happens if an insurer seeks recovery from a third-party tortfeasor where the insured's total loss has not been repaid in full. See R. Keeton, Insurance Law § 3.10(c)(2) at 160. The rule followed by the Appellate Division states that "out of the recovery from the third party the insured is to be reimbursed first, for the loss not covered by insurance and the insurer is entitled to any remaining balance, up to a sum sufficient to reimburse the insurer fully, the insured being entitled to anything beyond that." R. Keeton, Insurance Law § 3.10(2) at 161. See, e.g., Union Ins. Soc'y v. Consolidated Ice Co., 261 Mich. 35, 245 N.W. 563 (1932). Other possible rules are:

(2) The insurer is the sole beneficial owner of the claim against the third party and is entitled to the full amount recovered whether or not it exceeds the amount paid by the insurer to the insured. See, e.g., Travelers' Ins. Co. v. Brass Goods Mfg. Co., 239 N.Y. 273, 146 N.E. 377 (1925);
(3) The insurer is to be reimbursed first out of the recovery from the third party, and the insured is entitled to any remaining balance. See, e.g., Fort Worth Lloyds v. Haygood, 151 Tex. 149, 246 S.W.2d 865 (1952);
(4) The recovery from the third person is to be prorated between the insurer and the insured in accordance with the percentage of the original loss for which the insurer paid the insured under the policy. See, e.g., Pontiac Mut. County Fire & Lighting [Lightning] Ins. Co. v. Sheibley, 279 Ill. 118, 116 N.E. 644 (1917); General Exch. Ins. Corp. v. Driscoll, 315 Mass. 360, 52 N.E.2d 970 (1944); and
(5) The insured is the sole owner of the claim against the third party and is entitled to the full amount recovered, whether or not the total thus received from the third party and the insurer exceeds his loss. (i.e., this option rejects subrogation). [R. Keeton, Insurance Law § 3.10(a) at 161-62.]
[3]  Mrs. Culver claimed that INA's attorney assured her and her attorney that INA was entitled, as a matter of law, to reimbursement of the $82,373.12 it had paid her under the insurance policy plus 12% interest before the Culvers would be entitled to any portion of the subrogation proceeds; she also contended that INA's attorney told her and her attorney that the net subrogation recovery would not be in excess of $82,373.12 and that she had no alternative to accepting 20% of any recovery. Defendant, on the other hand, stresses that according to a letter sent to Mrs. Culver, it never represented that it was entitled to $82,373.12 plus 12% interest of any recovery, or that it was unlikely any recovery would not exceed what had been paid out.
