after stating the case: Eliminating immaterial matter, the record presents the following case: White sold to *562Piland a tract of land for some $3,500. Eor the purpose of securing the payment of the purchase money, Piland executed to Blount a deed in trust for the land. Thereafter, Piland executed to defendant W. S. Privott a deed in trust on the same land, also a tract belonging to his wife, to secure a note of $650 due defendant II. C. Privott. Both deeds were duly recorded. Subsequent to their execution, Piland sold to plaintiffs a portion of the land for $1,500, which was a full and fair price therefor. Pursuant to an arrangement between White, Piland and the plaintiffs, the purchase money was paid to White on account of his note, and he executed to plaintiffs the release set out in the record. Thereafter, the defendant W. S. Privott, pursuant to the power of sale in the deed in trust executed to him, sold the portion of the land which had not been sold to plaintiffs for the sum of $2,100, which he applied to the payment of the balance due on White’s note. He thereupon advertised and sold the portion of said tract conveyed by Piland to plaintiffs for the sum of $650. Plaintiffs, supposing that he had the right to sell, purchased and paid the amount. The question is, To whom does the $650 belong? If, upon these facts, the court be of the opinion that the defendant W. S. Privott was empowered to sell the land, plaintiffs cannot recover; otherwise, they are to have judgment. Defendant W. S. Privott was not a party to the arrangement between White, Piland and plaintiffs, and did not assent thereto. It is conceded that his rights could not be prejudiced by the arrangement between Piland, White and plaintiffs. The real question is whether he could take any benefit therefrom. It is manifest that, as matters stood before Piland sold to plaintiffs, the defendant W. S. Privott’s deed in trust was of no value. The proceeds of the land sold to plaintiffs for $1,500, and the remainder, sold for $2,100, were absorbed in paying White’s note. It is equally manifest that Privott’s power of sale was not affected by the arrangement, unless the admission that the amount paid by plaintiffs *563for tbe portion of tbe land purchased by tbem was a full and fair price therefor has the effect of preventing him from selling it under the power contained in his deed. White was entitled to have the proceeds of the sale to plaintiffs applied to his note. It is clear, upon the admissions in the case agreed, that defendants have suffered no* prejudice by the sale of the land to plaintiffs. They are in the same position as if Blount, trustee, had sold the land under the power in his deed and applied the proceeds to White’s note. If defendant W. S. Privott be permitted to sell the plaintiffs’ land and apply the proceeds to TI. O. Privott’s note, a tract of land conceded to be worth $3,600 is made to pay $4,250 of Piland’s debt, and plaintiffs are required to pay $2,150 for land conceded to be worth but $1,500. If, instead of selling under the power in his deed in trust, defendant W. S. Privott had brought suit for foreclosure, having all of the parties before the court, and the facts as set out in the record had, by appropriate pleadings, been brought to the attention of the court, what decree would have been rendered % Plaintiffs insist that, upon payment to White of the $1,500, they became subrogated to the rights of White, and that, pro tanto, they were, by substitution, the owners of the White note and entitled to the same security which he held therefor; that, as defendants admit they paid full value for the portion of the land conveyed to them, equity will not permit defendants to sell the land.
It is not very material to the determination of this appeal whether the plaintiffs’ equity be to enjoin a sale or, sale having been made, to demand the application of the proceeds to the discharge of the amount paid by them in reduction of White’s note. The equity upon which their claim is founded is defined to be “the substitution of another person in the place of a creditor, so that the person in whose favor it is exercised succeeds to the rights of the creditor in relation to the debt,” * * * or “that change by which another person is put into the place of a creditor, so that the rights and *564securities of the creditor pass to the person who, by being sub-rogated to Mm, enters into bis right. It is a legal fiction, by force of which an obligation extinguished by a payment by a third person is treated as still subsisting for the benefit of this third person who is thus substituted to the rights, remedies and securities of another. The party who is subrogated is regarded as entitled to the same rights, and, indeed, as constituting one and the same person with the creditor whom he succeeds.” Sheldon Sub., 2; 27 Am. and Eng. Enc., 206; Davidson v. Gregory, 132 N. C., 389. Subrogation is of equitable origin, not dependent upon contract, and is always invoked to prevent injustice. It will never be permitted to work to the prejudice of the rights of others or produce injustice. Its limitations are well marked and illustrated in numerous cases found in the reports. Carter v. Jones, 40 N. C., 196; Springs v. Harver, 56 N. C., 96.
Are the plaintiffs, upon the facts set out in the record, entitled to invoke this equity ? It is manifest that all parties have acted in good faith, plaintiffs paying full value for' the land and applying the purchase money to the first lien. If they had taken an assignment of AVhite’s debt pro tanto they would have “stood in his shoes” in respect to the security which he held. The rights of the defendants would not have been disturbed. Nothing was taken from them, nor was their security reduced in value.
It would be a manifest hardship to compel the plaintiffs to pay a second time for the land. Smith, G. J., thus disposes of a somewhat analogous case: “The plaintiff occupies the place of the trustee, so far as the mortgagor is concerned, and he has paid the money into the trust fund in the hands of the mortgagees, which, if the purchase were upheld, would go in diminution of the indebtedness, and, if not, must be restored to the plaintiff, and this would be a self-adjustment pro tanto, should the plaintiff again become the purchaser.” Gibson v. Barbour, 100 N. C., 192; Jones v. Leonard, 109 N. C., 643. *565It appears that it was mutually understood and agreed that the plaintiffs were to take and hold all the right and interest of White and of Piland in the land; that the plaintiffs are colored men, ignorant of their rights in law and fact. Their case comes clearly within the principle announced in Robinson v. Leavitt, 7 N. H., 99: “There are cases in which a party who has paid money due upon a mortgage is entitled, for the purpose of effecting the substantial justice of the case, to be substituted in the place of the encumbrance and treated as assignee of the mortgage, and is enabled to hold the land as assignee, notwithstanding the mortgage itself has been cancelled and the debt discharged. The true principle is that when money due upon a mortgage is paid it shall operate as a discharge of the mortgage or in the nature of an assignment of it, as may best serve the purpose of justice and the just intent of the parties. Many cases state the rule in equity to be that the encumbrance shall be kept on foot or considered extinguished or merged, according to the intent or interest of the party paying the money. * * * And it makes no difference * * * whether the party, on payment of the money, took an assignment of the mortgage or a release, or whether a discharge was made and the evidence of the debt cancelled. The debt itself may be still held to subsist in him who paid the money, as assignee, so far as it ought to subsist, in the nature of a lien upon the land, and the mortgage be considered in force for his benefit, so far as he ought in justice to hold the land under it, as if it had been actually assigned to him.” That a purchaser of mortgaged lands who pays off the prior encumbrance comes within the class of those entitled to subrogation is established by abundant authority. We find in our investigation the exact question presented and decided in Walker v. King and others, 45 Vermont, 525. Plaintiff held a mortgage executed by one Gyrus Safford upon land subject to prior mortgages. Safford sold the land to defendants upon the consideration that they would discharge *566the prior mortgages. Tbis being clone, the defendants went into possession. Plaintiff filed bis bill for foreclosure of bis mortgage. Wheeler, J., said: “When defendants paid off the first two" mortgages and $800 of the third, they, by sub-rogation, acquired all the rights which the respective mortgagees had'by virtue of their mortgages, to the extent to which they paid off the mortgages. * * * Tim mortgages, to the extent to which they were paid off by the defendants, constituted a part of their title to the premises, and the orator was always bound to respect those mortgages to that extent. These defendants, as between their vendor and themselves, were not bound to pay the orator’s mortgage, but were to have the premises for what they were to pay on the others; and, should they be compelled now to either redeem the orator’s mortgage or permit him to redeem the premises upon payment of what they paid at the time of their purchase, without interest, it would be compelling them to pay the amount of his mortgage more than they were to pay for the premises.” The principle upon which the plaintiffs’ right to recover rests cannot be stated more forcibly or cleanly. Sheldon Sub., sec. 28; Gans v. Theim, 93 N. Y., 225. The equity for subrogation has been applied by us in cases where judicial sales have been vacated for fatal defects, and the purchaser who has paid the purchase money which has been applied to the discharge of debts or liens for' which the land was liable has been sub-rogated to the rights of the creditors whose debts were paid.
The learned counsel for plaintiffs further insists that, independent of the equity for subrogation, when defendant W. S. Privott first sold under his power, the proceeds should have been applied to the debt secured by his deed; that the sale was subject to the deed to Blount, or, in other words, he sold what he had — the equity of redemption. , We concur in this view, as a general rule. Bobbitt v. Stanton, 120 N. C., 253. It appears, however, that there is a provision in the defendant W. S. Privott’s deed in trust requiring him to dis*567charge tbe White note from tbe proceeds of tbe sale of Piland’s land before resorting to tbe trapt belonging to bis wife. This takes tbe case ont of tbe general rule. We can see no reason why, having applied tbe $2,100 to tbe discharge of White’s note, defendant trustee is not entitled to sell tbe other tract in bis deed. Unless there be some reason to tbe contrary not appearing upon tbe record, both debts may be paid and tbe plaintiffs protected. In other words, equity regarding that as done which ought to be done, tbe rights of all parties will be preserved and enforced in strict accordance with their original intention and agreement, thus illustrating tbe wisdom and practical value of those maxims and principles of equity which have been evolved from tbe labors of tbe great chancellors who have adorned tbe equity jurisprudence of England and this country.
We have considered tbe case upon tbe facts agreed and tbe form in which they are submitted to us. We think that, independent of this agreement, tbe admission that tbe plaintiffs were ignorant colored men, not knowing their rights, and being advised by tbe defendant W. S. Privott, who was honestly mistaken, entitles them to relief. Equity disregards mere forms and looks at tbe substance of things.
Tbe judgment must be
Affirmed.