
247 Md. 714 (1967)
234 A.2d 611
THE FINANCE COMPANY OF AMERICA
v.
HELLER, ET AL.
[No. 591, September Term, 1966.]
Court of Appeals of Maryland.
Decided November 7, 1967.
The cause was argued before HAMMOND, C.J., and HORNEY, MARBURY, BARNES and FINAN, JJ.
William O. Goldstein and Alan Meyers for appellant.
Theodore C. Mitchell for appellees.
HORNEY, J., delivered the opinion of the Court.
*716 The question presented by this appeal is whether a mortgagor-grantor of land who conveys his equity of redemption therein subject to the mortgage and upon default of the grantee makes payments on the mortgage to protect his interest, may be subrogated to the rights of the mortgagee in a subsequent foreclosure proceeding to the extent of the payments made.
William S. Heller and his wife entered into a written contract with George E. Banks, III, wherein it was agreed that if the Hellers should purchase a certain tract of land they, in turn, would convey a portion of it to Banks; that the buyers would obtain a purchase money mortgage on the entire tract; that when the portion was conveyed to Banks, he would pay a proportionate part of the mortgage debt and taxes; and that the Hellers would have a right of subrogation in the event they were compelled to make any of the mortgage payments Banks agreed to pay. The agreement was never recorded.
Subsequently, the Hellers, having bought the land in question and executed a purchase money mortgage thereon to the Baltimore Federal Savings and Loan Association, conveyed a part of the tract of land to Banks subject to the mortgage. Later Banks executed a second mortgage to The Finance Company of America, but he made no payments on either mortgage. The Hellers, to protect their interest in the land, had to make payments for Banks of $2706.15 on the first mortgage and real estate taxes of $93  a total of $2799.15.
Ultimately, a relative of the Hellers, having become the assignee of the first mortgage, instituted a foreclosure proceeding against the Hellers and Banks and sold the entire tract. After the payment of costs and the balance due the assignee under the foreclosed mortgage, there was a surplus of $7384.36. The court auditor distributed the entire sum to the finance company in partial satisfaction of its second mortgage, whereupon the Hellers filed exceptions to the report of the auditor asserting that they were entitled to priority in the surplus proceeds to the extent of the payments (aggregating $2799.15) they had made for Banks on the first mortgage. The chancellor, basing his decision on the doctrine of equitable subrogation (and not the subrogation agreement between the parties), ordered distribution of $2799.15 to the Hellers and the balance ($4585.21) *717 to the second mortgagee. On appeal, the finance company contends that even if the doctrine of subrogation is applicable it was not a bar to the collection of the debt secured by its mortgage. We think the chancellor was right and that his order must be affirmed.
When one pays a debt for which he is not primarily liable in order to protect his interest, the courts generally apply the doctrine of equitable subrogation and allow him to stand in the place of the creditor with the right to enforce whatever security there may be for the payment of the debt. 5 Tiffany, Real Property (3rd ed.), § 1506; 4 Pomeroy, Equity Jurisdiction (5th ed.), § 1212; Mullen, The Equitable Doctrine of Subrogation, 3 Md. L. Rev. 201.
Ordinarily, the question as to whether one is entitled to subrogation, depends on whether the claimant is a mere volunteer and, if not, whether he is on equitable principles entitled to such subrogation as against other claimants. Milholland v. Tiffany, 64 Md. 455, 460, 2 Atl. 831, 834 (1886). A mortgagor may or may not be entitled to subrogation depending on whether he is primarily liable for the whole debt. See Tiffany, op. cit., § 1507, where it is stated:
"In case the mortgage debt is paid by one of the parties to a transfer of the mortgaged land or of a part thereof, the question whether the party paying has a right of subrogation will depend upon the character or circumstances of the transfer. If the property was transferred subject to the mortgage, though without any assumption of the debt by the transferee, the mortgaged property is subject to a primary liability for the debt, and consequently, if the transferor pays the debt, he is subrogated to the rights of the mortgagee against the property."
Our predecessors, applying these principles in Parsons v. Urie, 104 Md. 238, 64 Atl. 927 (1906), said (at p. 249):
"[W]here a mortgagor conveys premises subject to the lien of the mortgage, the amount of the mortgage debt being deducted from the purchase price, the premises *718 remain a primary fund for the payment of the debt, and if the mortgagor is compelled to pay the debt he may be subrogated to the rights of the mortgagee."
In Robertson v. Mowell, 66 Md. 530, 8 Atl. 273 (1887), the Court went a step further. There, after noting that in most cases the doctrine of substitution or subrogation is applied in behalf of one who is under an obligation to pay the debt of another, it was held (as was implied in Milholland v. Tiffany, supra, would be done in a proper case) that the doctrine is not necessarily confined to such cases and may be applied on equitable principles in behalf of one, who at the instance and request of a debtor, pays a lien or encumbrance which he is under no legal obligation to pay, provided it does not interfere with intervening rights and encumbrances of another. Also see Schnader, Inc. v. Cole Building Co., 236 Md. 17, 202 A.2d 326 (1964). Cf. Maryland Title & Escrow Corp. v. Kosisky, 245 Md. 13, 225 A.2d 47 (1966).
In the case at bar, where a part of the land was transferred subject to the mortgage, where the entire tract  that owned by the Hellers as well as that owned by Banks  was primarily liable for the mortgage debt, and where the Hellers made the mortgage payments due by Banks, it is clear that the second mortgagee was in no worse position than it would have been had the Hellers made none of the payments due by Banks. This is so because the second mortgagee knew that the conveyance of the equity of redemption was subject to the first mortgage and that the entire tract of land was therefore primarily liable for the debt secured thereby. The only security the second mortgagee got was the equity of redemption in a part of the land after the discharge of the first mortgage. Furthermore, since the second mortgage was not an intervening encumbrance, the payments made by the Hellers to protect their interest in nowise interfered with the rights and encumbrance of the second mortgagee.
The claim of the finance company that the failure of the grantors to record the subrogation agreement rendered it ineffective as against its mortgage is without merit because the application of the equitable doctrine of subrogation to the facts of *719 this case made the recording statutes inapplicable. The claim that the lower court should have applied the doctrine of unjust enrichment in behalf of the finance company overlooks the fact that subrogation is a method of preventing unjust enrichment.
Order affirmed; the appellant to pay the costs.
