delivered the opinion of the court:
In 1877, the appellant, H. O. Hudson, purchased of Gr. G. Yenable 400 acres of land, a portion of a tract containing about 1,250 acres, lying in the county of Halifax. At the time of the purchase the tract was encumbered by a deed of trust to secure the payment of a debt of $8,000 due by the said Yenable to D. S. Marrow, guardian, and by a mortgage to secure the payment of a debt due by the said Yenable to E. O. and A. P. Yenable. The first was executed in 1871, the last in 1875, and both were duly recorded. The consideration of the purchase was $2,400, of that sum the appellant paid to Yenable, the vendor, $1,200 in cash, who, in turn, paid $500 of it to Marrow. The deferred payments, amounting to $1,200, were paid by the appellant directly to Marrow, making in all $1,700 of the purchase money paid to Marrow.
*245During the same year, Marrow and the trustee in the deed for his benefit released to Venable all their right, title and interest by virtue of the; said trust deed in and to the land purchased by the appellant. In the deed of release it was recited that its object was to give to the appellant, Hudson, a good title to the land, and that Venable had given to Marrow other security satisfactory to him. On the same day Venable conveyed to Winn, trustee, certain crops to secure payment of the balance of the debt due by him to Marrow, which in the deed was stated to he $600. It does not appear that Marrow knew at the time of the execution of this deed, or that he realized anything on account of it. In his deposition taken in the cause, he testifies that he did not hear of it until nearly two years after its execution, and that the security referred to in his deed of release to Venable was understood by him to embrace the balance of Venable’s real estate, after the sale to Hudson, which was subject to his trust deed.
At the time of Hudson’s purchase, Venable owned a tract of land in Mecklenburg county, which was included in the trust deed to secure Marrow, and which was also subject to the lien of two judgments obtained against Venable in the circuit court of that county in 1875, and duly docketed in that county, one in favor of Deane & Carrington, upon which a balance of $20.53 was reported as due, the other for $38.48, in favor of R. W. Powers & Co.
Subsequently other judgments were obtained against Venable in the same court.
This suit was brought by a judgment creditor to subject the real estate of Venable to the satisfaction of the liens thereon. In the progress of the cause, an amended hill was filed, to which Hudson, the appellant, was made a party defendant, the object of which was to subject the land bought by him for the same purpose. Under a decree in the cause, all the real estate of the defendant, Venable, was rented out for the year 1878 for the sum of $500, of which $400 was for the Halifax land, and $100 *246for the Mecklenburg land, of which 111 acres at that time remained unsold. Under a subsequent decree the whole of the real estate was sold, the proceeds of the remnant of the Mecklenburg tract, amounting to the gross sum of $234.
The proper accounts having been taken and returned, and the cause coming on to be heard, it was decreed that for any .deficiency after exhausting the proceeds of the sale of the Halifax land, the four hundred acres purchased by. the appellant was liable as against the mortgagees, E. O. and A. P. Yenable, to the satisfaction of their mortgage, without any credit for the payments made by him and applied to the discharge of the senior lien in favor of Marrow. And by another decree it was ordered that unless Hudson should, within a given time, pay the balance due on account of the said mortgage, which, at that time, amounted to the sum of $925, with interest, the land bought by him should be sold to satisfy the same. From these decrees Hudson obtained an appeal to this court.
We think these decrees are erroneous, and must be reversed.
1. The appellant was the purchaser of the equity of redemption, and upon well established principles; was entitled to be subrogated to the rights of Marrow to the extent that the purchase money paid by him was applied to the discharge of the Marrow debt. This he was denied by the decrees complained of. As pointed out by Judge Staples in delivering the opinion of the court in Gatewood v. Gatetvood, 75 Va. 410, there is a distinction between the right to an assignment of a mortgage debt and the right of subrogation to the lien of the mortgage cred^ itor. In the former case, the right being-dependent upon intention and the act of the parties does not ordinarily attach until the whole debt is paid. But not so in the latter. The doctrine of subrogation is not dependent upon contract, nor upon privity between the parties as between whom it is applied. It is the creature of equity, and is founded upon principles of natural justice. At first it was applied Only in favor of those who were bound by the original security with the principal debtor; but it *247has been extended, and is now applied in favor of all persons who are required to pay the debt of another for the protection of their own interests. Among such persons are embraced purchasers of the equity of redemption, with or without notice of existing liens. Therefore, when a purchaser of land pays off a debt of his grantor secured by a trust deed upon the premises as a part of the purchase money, and to protect his own title from sale, the payment is not a voluntary payment by a stranger, and he will be subrogated to the lien of the deed of trust as against an intervening lien against his grantor. In such cases a court of equity will even keep alive the lien in favor of the purchaser, notwithstanding it has been formally released without his knowledge and consent. Young v. Morgan, 89 Ill. 199; Lynch v. Hancock, 14 S. C. 66; McCormick’s adm’or v. Irwin, 35 Penn. Stat. 111; Gatewood v. Gatewood, 75 Va. 407 and cases cited.
It is true that in his answer to the amended hill the appellant did not claim specifically the right of subrogation. But upon the facts alleged and by the evidence established, and upon which he claimed to be entitled to a credit for the purchase money paid by him, and to hold the land in his possession discharged of liens, we think a case for the application of the doctrine was substantially made, and that it ought to have been applied. In the language of Judge Carr, in Enders v. Brune, 4 Rand. 447, “it has nothing of form, nothing of technicality about it, and he who in administering it would stick to the letter, forgets the end of its creation, and perverts-the spirit which gave it birth. It is the creature of equity, and real essential justice is its object.”
2. The circuit court also erred in respect to the application of the proceeds derived from the renting and from the sales of the debtor’s real estate under its previous decrees.
The Marrow debt, as we have seen, was secured on both the Mecklenburg and Halifax-lands, while the debt due the mortgagees, B. O. and A. P. Yenable, was secured on the latter only. *248The whole of the proceeds of the latter, after satisfying a prior lien, having heen exhausted in the payment of the Marrow debt, the mortgagees were entitled to be substituted to Marrow’s lien in respect to the proceeds of the Mecklenburg land, after satisfying the judgments in favor of Deane and Carrington and E. W. Powers & Company. The rent for the year 1818 should be applied in the same manner. Beverly v. Brook, 4 Grat. 187; Lewis v. Caperton, 8 Id. 167. This the appellant, occupying as he does the position of a quasi surety, had the right to require for the protection of his rights and interests.
The doctrine of marshalling assets is founded upon the maxim sic utere tuo ut non alien-urn laedas; and the general principle is, that if one party has a lien on, or interest in, two funds for a debt, and another party has a lien on, or interest in one only for another debt, the latter has a right in equity to compel the former to resort to the other fund in the first instance for satisfaction, if that course is necessary for the satisfaction of the claims of both parties, whenever it will not trench upon the rights, or operate to the prejudice of the party entitled to the double fund. 1 Story’s Eq., sec. 688, and cases cited.
This sufficiently disposes of the case. Other questions have been discussed by counsel, but we deem it unnecessary to consider them.
The decrees of the circuit. court must be reversed, and the cause remanded for such further proceedings to be had in conformity with the views herein declared as may be necessary and proper.
The decree was as follows:
This day came again the parties by their counsel, and the court having maturely considered the transcript of the record of the decrees aforesaid, and the arguments' of counsel, is of opinion, for reasons stated in writing, and filed with the record, that the said decrees are erroneous in the following particulars, viz:
*2491. In denying to the appellant credit for the amount of the purchase money, to-wit: $1,700, paid by him on account of the purchase of the four hundred acres of land conveyed to him hy the defendant, Yenahle, and wife, and applied to the discharge of the debt due hy the said Yenahle to D. S. Marrow, and secured in part hy deed of trust on the land so conveyed. To that extent the appellant was entitled to be subrogated to the rights of Marrow under the said trust deed, and it was error not to so decree.
2. In respect to the application directed to he made of the proceeds derived from the renting and from the sales of the said Yenable’s real estate under previous decrees.
The whole of the proceeds derived from the sale of the Halifax land, after satisfying the debt due to A. G. Jeffress, having been exhausted in the payment of the debt due the said Marrow, the mortgagees, E. O. and A. P. Yenahle, were entitled to be substituted .to the rights of the said Marrow in respect to the proceeds derived from the sale of the one hundred and seventeen acres of land lying in the county of Mecklenburg, after satisfying the judgments reported in favor of Deane and Carrington and R. W. Powers & Co. The rent derived from the said lands, for the year 1878, should be applied in the same manner, and it was error not to so decree.
It is therefore decreed and ordered that, in the particulars aforesaid, the said decrees be reversed and annulled, and in all other respects he affirmed, and that the appellees pay to the appellant his costs by him expended in the prosecution of his appeal aforesaid here.
And this cause is remanded to the said circuit court for such further proceedings to be had, in conformity with-the principles herein declared, as may he necessary and proper.
Which is ordered to be certified to the said circuit court of Mecklenburg county.
Decree reversed.