
82 Wis.2d 235 (1978)
262 N.W.2d 114
ROCK RIVER LUMBER CORPORATION, Plaintiff-Appellant,
v.
UNIVERSAL MORTGAGE CORPORATION OF WISCONSIN, Defendant-Respondent:
ROCK RIVER DISTRIBUTORS, INC., and others, Defendants-Appellants: MINT ENTERPRISES, INC., and others, Defendants.
UNIVERSAL MORTGAGE CORPORATION OF WISCONSIN, Plaintiff-Respondent,
v.
MINT ENTERPRISES, INC., Defendant:
ROCK RIVER LUMBER CORPORATION, Defendant-Appellant.
Nos. 75-281, 75-282.
Supreme Court of Wisconsin.
Submitted on briefs January 5, 1978.
Decided February 7, 1978.
*238 For the appellants the cause was submitted on the briefs of Edward Grutzner and Grutzner, Byron & Holland, S. C. of Beloit.
For the respondent the cause was submitted on the brief of Stuart G. Grady of Port Washington.
CONNOR T. HANSEN, J.
The parties to this appeal and review raise a number of issues. After consideration of all issues presented, we believe the resolution of one issue is dispositive of this case and that the issue can properly be stated as follows:
Under the facts of this case, when Universal Mortgage Corporation of Wisconsin (hereinafter Universal) advanced money to discharge the existing mortgage of Wisconsin Savings and Loan Association of Milwaukee (hereinafter Wisconsin Savings and Loan), did Universal become subrogated to the rights of the savings and loan association and, therefore, to priority as against construction lien claimants who would otherwise have been entitled to priority as against the Universal Mortgage?
On December 28, 1971, Mint Enterprises, Inc. (hereinafter referred to as Mint) purchased five contiguous lots and mortgaged the lots to Wisconsin Savings and Loan to secure payment of a loan in the amount of $93,800. The mortgage was recorded on January 17, 1972, prior to the filing of any lien claims, and therefore *239 had undisputed priority over all subsequent lien claims, pursuant to sec. 215.21, Stats.[1]
Mint then contracted with Stanley Mannino for the construction of five houses on the lots, and gave Mannino authority to select subcontractors.
On April 7, 1972, after the visible commencement in place of the work of improvement, Mint refinanced its debt to Wisconsin Savings and Loan by obtaining a loan of $90,000 from Universal. The loan was evidenced by Mint's promissory note in the amount of $90,000, and was secured by a mortgage against the five lots. The mortgage provided, in part:
"... and the mortgagor hereby covenants that the mortgagor is seized of a good title to the real estate in fee simple, free and clear of all encumbrances, except as follows: [blank] and the mortgagor will forever warrant and defend the same to the mortgagee against all claims whatsoever."
The loan from Universal was used, almost in its entirety, to pay the debt to Wisconsin Savings and Loan in full. A satisfaction of the Wisconsin Savings and Loan mortgage was recorded on May 17, 1972.
[1]
The mortgage given by Mint to Universal, although executed on April 7, 1972, was not recorded until July 5, 1972. Because the visible commencement of the work of improvement preceded the recording of Universal's mortgage, the various subcontractors and materialmen would, in the absence of subrogation, be entitled to priority as *240 against the mortgage recorded July 5, 1972. See: Mortgage Associates v. Monona Shores, 47 Wis.2d 171, 186, 187, 177 N.W.2d 340 (1970).
Thereafter, Rock River Lumber Corporation, one of the lien claimants, commenced an action to foreclose its lien, and Universal commenced an action to foreclose its mortgage. These actions were consolidated for trial.
The trial court determined that seven lien claimants had valid lien claims in a total amount of $19,557.12. However, the trial court also determined that the claim of Universal was entitled to priority over the lien claims because Universal was subrogated to the priority of the earlier mortgage. Judgment was entered accordingly.[2]
Rock River Lumber Corporation, representing the lien claimants, appeals from that portion of the judgment which accorded Universal priority over the lien claims. Universal, by notice of review, challenges the validity of the construction liens.
The parties agree that the mortgage of Wisconsin Savings and Loan was entitled to priority over all the lien claims, by virtue of sec. 215.21 (4), Stats. For this reason, if Universal is subrogated to the rights of Wisconsin Savings and Loan, Universal is entitled to priority over the lien claimants, and the other issues raised by the parties are of no consequence.
The question, then, is whether the doctrine of subrogation is applicable to the facts of this case.
[2, 3]
Subrogation is an equitable doctrine invoked to avoid unjust enrichment, and may properly be applied whenever a person other than a mere volunteer pays a debt which in equity and good conscience should be satisfied *241 by another. D'Angelo v. Cornell Paperboard Products Co., 19 Wis.2d 390, 399, 400, 120 N.W.2d 70 (1963); Dairyman's State Bank v. Tessman, 16 Wis.2d 314, 322, 114 N.W.2d 460 (1962). As a rule, however:
"... the right of a party to subrogation, by reason of advances made to a debtor, depends upon (1) his being secondarily liable; or (2) the necessity for acting to protect his own interests; or (3) an agreement that he is to have security...." Bank of Baraboo v. Prothero, 215 Wis. 552, 558, 255 N.W. 126 (1934). (Emphasis added.)
In the instant case there is no suggestion that the first or second of these categories are applicable. The trial court held that the facts of this case put it within the third category and that subrogation arises from an agreement of the parties, Mint and Universal.
[4]
Under what is generally termed "conventional subrogation," a lender will be granted subrogation where money is advanced in reliance upon a justifiable expectation that the lender will have security equivalent to that which his advances have discharged, see: Wilton v. Mayberry, 75 Wis. 191, 43 N.W. 901 (1889), provided that no innocent third parties will suffer. See: Union Trust Co. of Maryland v. Rodeman, 220 Wis. 453, 264 N.W. 508 (1936). Equity will treat such a transaction as tantamount to an assignment of the original security. See: Home Owners' Loan Corp. v. Dougherty, 226 Wis. 8, 9, 275 N.W. 363 (1937).
[5]
Although such conventional subrogation has been said to rest on contract, it is a doctrine of equity, and is applied or denied upon equitable principles. American Ins. Co. v. Milwaukee, 51 Wis.2d 346, 351, 353, 187 N.W.2d 142 (1971). The object of subrogation is "... to do substantial justice independent of form or contract *242 relation between the parties...." Hughes v. Thomas, 131 Wis. 315, 319, 111 N.W. 474 (1907).
[6]
Thus it can be said that subrogation arises, not as a direct legal consequence of the contract of the parties, but rather as a matter of doing justice after a balancing of the equities, and that the agreement is merely a consideration although an important considerationin determining whether subrogation is appropriate. Osborne, Handbook on the Law of Mortgages (2d ed., hornbook series, 1970), secs. 277, 280, pp. 561, 563, 567; 73 Am. Jur.2d, Subrogation, sec. 9, pp. 604, 605. Even where a definite agreement for subrogation is shown, therefore, subrogation will be denied where it would lead to an uncontemplated and inequitable result. Union Trust Co. of Maryland v. Rodeman, supra, at 469.
From the foregoing it follows that conventional subrogation will be available only where a definite agreement of the parties is shown and where a balancing of the equities favors application of the doctrine. In the instant case the trial court determined that the mortgage held by Universal "... was executed in substitution for the existing mortgage..." and that the loan from Universal to Mint was executed "... under a definite agreement for security in the form of a first mortgage...." As findings of fact, these determinations must be upheld unless they are contrary to the great weight and clear preponderance of the evidence. Stueck v. Le Duc, 57 Wis.2d 735, 741, 205 N.W.2d 139 (1973).
[7]
The lien claimants point out that after the mortgage to Universal was executed, Universal obtained various lien waivers from subcontractors. They argue that these actions refute any implication that Universal expected to be subrogated to the priority of the earlier mortgage. While receipt of the lien waivers is a relevant factor and may have bearing upon the understanding of the parties, *243 the reasons of Universal in obtaining some waivers cannot be determined from the record. Moreover, it cannot be said that the findings of the trial court are contrary to the great weight and clear preponderance of the evidence.
[8]
The record shows that during trial, Greg A. James, vice president of Universal, was asked whether Universal's mortgage was to be a substitute for an existing mortgage, and that he replied "Yes, there was an existing mortgage prior to ours." James testified that Universal knew that Wisconsin Savings and Loan held a mortgage prior to its own, and he further testified that the loan from Universal was to be used to satisfy the existing mortgage. This testimony was uncontradicted.
Moreover, the mortgage given to Universal by Mint stated in part:
"... the mortgagor hereby covenants that the mortgagor is seized of a good title to the real estate in fee simple, free and clear of all encumbrances, except as follows:
"...."
No exceptions were indicated. In form, therefore, the mortgage was a first mortgage.
On the basis of this evidence the trial court found that Mint had given Universal a first mortgage and that Universal was entitled to subrogation as one advancing money for the discharge of an existing mortgage "... under a definite agreement that [the lender] have security in the form of a first mortgage," Bank of Baraboo v. Prothero, supra, at 558, 559; Home Owners' Loan Corp. v. Papara, 241 Wis. 112, 116, 117, 3 N.W.2d 730 (1942).
In Bank of Baraboo v. Prothero, supra, a bank advanced a sum sufficient to pay off a mortgage of $10,000. In consideration the bank received a first mortgage upon the premises. On these facts, this court concluded that *244 the bank "... advanced the money under a definite agreement that [it] have security in the form of a first mortgage, and is within the doctrine of the cases which give subrogation." Bank of Baraboo v. Prothero, supra, at 558, 559. The appellants would distinguish this case on the ground that the bank also held a second mortgage on the premises in question. The bank was granted a subrogation, respondents argue, not because of an agreement, but because it was compelled to advance the money to protect its existing interest in the property. However, the decision was squarely grounded on the agreement of the parties, and this court expressly observed that it was unnecessary to determine whether the bank was entitled to subrogation on the ground that it had acted to protect its interests. Bank of Baraboo v. Prothero, supra, at 559.
In Home Owners' Loan Corp. v. Dougherty, supra, the Home Owners' Loan Corporation had advanced money for, among other things, the satisfaction of an existing mortgage. In exchange, the borrower gave the bank a note and mortgage. The trial court found that there was a definite agreement that the lender would have security in the form of a first mortgage, and therefore granted subrogation. On appeal this court determined that the Bank of Baraboo v. Prothero Case, supra, was controlling, and affirmed the judgment of the trial court.
In Home Owners' Loan Corp. v. Papara, supra, money was advanced for the satisfaction of an existing mortgage and for other purposes. The loan was secured by a mortgage which later proved invalid because several signatures had been forged. Nevertheless, this court held that the lender:
"... stands in the position of one entitled to the benefit of the doctrine of subrogation for `it advanced the money under a definite agreement that plaintiff have security in the form of a first mortgage." Home *245 Owners' Loan Corp. v. Papara, supra, at 116, quoting Bank of Baraboo v. Prothero, supra, at 558, 559.
The appellants would distinguish Home Owners' Loan Corp. v. Papara, supra, on the basis that the new mortgage taken by the lender in that case proved to be invalid, and that subrogation was therefore appropriate to protect the lender, who would otherwise have been unsecured.
However, the decision of this court in the Papara Case was plainly founded on the agreement of the parties and not on the invalidity of the later mortgage. In holding that subrogation was appropriate, the court relied upon the Prothero and Dougherty Cases, neither of which involved an invalid mortgage. In addition, the court found it unnecessary to determine whether the second mortgage could be enforced against the wife on a theory of equitable estoppel, because the lender was entitled to subrogation on the basis of the agreement of the parties. We conclude that the decision of the trial court in the instant case is entirely consistent with the previous decisions of this court and that Universal stands in the position of one entitled to subrogation.
It therefore remains to be determined whether the application of the doctrine of subrogation would for any reason be inequitable in the circumstances of this case. Home Owners' Loan Corp. v. Papara, supra, at 117; Union Trust Co. of Maryland v. Rodeman, supra, at 469. In particular it is necessary to consider whether the rights of any third party have intervened in such a way as to render it inequitable to grant subrogation. See: Bank of Baraboo v. Prothero, supra, at 559.
The mortgage to Universal was executed on April 7, 1972. A satisfaction of the Wisconsin Savings and Loan mortgage was recorded May 17, 1972. However, the mortgage to Universal was not recorded until July 5, 1972. The appellants contend that as a result of the *246 failure to promptly record its interest, Universal has forfeited any right to subrogation.
[9]
It has been said that a lender's right to subrogation may be lost through delay in asserting the claim to subrogation or rights under the new security, if intervening lienors are thereby prejudiced. 73 Am. Jur.2d, Subrogation, sec. 105, pp. 664, 665; Annot. 70 A.L.R. 1396, 1416, 1417 (1931).
In the Papara Case, supra, at 118, this court emphasized that subrogation did not, under the circumstances of that case:
"... cut off any intervening rights of one relying upon the extinguishment of the prior mortgage nor of one who has innocently placed himself in a position of disadvantages and would be injured by the application of the doctrine...."
Similarly, in the Prothero Case, supra, subrogation gave the subrogee priority over the respondent's lien for the value of labor and materials used in plumbing and heating repairs. This court stressed that the original mortgage was existent at the time the repairs were undertaken and was prior to the respondent's lien, and that the respondent's rights therefore could not be said to have intervened, so as to render subrogation inequitable. Bank of Baraboo v. Prothero, supra, at 559.
Under certain circumstances, a delay in recording a subrogee's mortgage could well operate to the prejudice of any intervening lienors. In the instant case, approximately seven weeks elapsed between the recording of the satisfaction of the savings and loan mortgage and the recording of Universal's mortgage. If visible commencement of the work of improvement had occurred during that period, lien claimants might well argue that they had acted in reliance upon the recorded satisfaction as indicating that there would be no interests prior to their liens.
*247 [10]
No such difficulty is presented here, however. The record shows that the original mortgage was of record prior to the filing of any lien claims, and was therefore entitled to priority under sec. 215.21 (4), Stats. From the record it also appears that all but one of the lien claimants first provided labor or materials while the original mortgage was in existence. Their claims were thus subject to the original mortgage. The remaining lien claimant, Rock River Distributors, did not begin work until after Universal's mortgage was recorded, and its claim was therefore subject to Universal's mortgage.
As in the Papara Case, supra, subrogation in this case does not "... cut off any intervening rights of one relying upon the extinguishment of the prior mortgage...." Home Owners' Loan Corp. v. Papara, supra, at 118. There is no indication that any third parties were prejudiced by the delay in recording the mortgage or that subrogation would be in any other way inequitable. Universal was therefore entitled to subrogation, and the judgment of the trial court is affirmed.
By the Court.Judgment affirmed.
NOTES
[1]  Sec. 215.21, Stats., concerning mortgage loans by savings and loan associations, provides in part:

". . .
"(4) PRIORITY OF ASSOCIATION'S MORTGAGES. (a) All mortgages described in this section shall have priority over all liens, except tax and special assessment liens, upon the mortgage premises and the buildings and improvements thereon, which shall be filed subsequent to the recording of such mortgage."
[2]  A receiver was appointed, and the property was sold for an amount less than Universal's claim. Universal was awarded the net proceeds of the sale and a deficiency judgment of $15,048.93 for principal and $13,735.93 for interest.
