after stating the case: The court should not have ordered an amendment of the original complaint. It was quite sufficient, in its allegations, to warrant a recovery upon the theory of subrogation or that of contract. The prayer does not narrow the scope of the pleading to its own limits, but a party can recover now according to the facts he states in- his pleading, and not necessarily or only according to his prayer. Voorhees v. Porter, 134 N. C., 591; Knight v. Houghtalling, 85 N. C., 17; Council v. Bailey, 154 N. C., 54; Silk Co. v. Spinning Co., ibid., 421, in which cases we said that the special prayer of the plaintiff for other relief does not deprive him. of that to which he is entitled upon the allegations of his complaint. The sole point of law involved in this appeal is as to the right of plaintiff (holder of the ten purchase-money notes) to recover' of defendant Rogers, Misenheimer, Miss Brown, and Mrs. Purse, nee Smith, the money secured thereby, all of said defendants having personally assumed the payment of said notes.
In cases of this kind a recovery by the mortgagee from a vendee of the mortgagor of a deficiency in the mortgage debt *591after foreclosure Las been, -allowed on two grounds. Many of tbe courts of this country — probably a large majority — allow recovery in such a case upon the broad principle that a third person may maintain an action on a contract made for his benefit. Though the present case seems to present a good opportunity for the application of that principle, yet from a consideration of the decisions of this Court they appear hot to have gone so far.
The other ground upon which a recovery has been allowed against a grantee of the mortgagor is under the doctrine of sub-rogation, by which, in equity, a creditor m,ay have the benefit of all collateral rights, remedies, and securities for the payment of the debt which a person standing in the relation of a surety for others holds for his indemnity. It has been held that an agreement by the purchaser of an equity of redemption with his vendor that he will assume and pay the mortgage debt will render him personally liable, not only to his grantor, but also directly to the holder of the mortgage. The original doctrine, which is still sometimes advanced, was that this right of the mortgagee to hold the purchaser of the equity of redemption, by reason of the latter’s agreement with the mortgagor to assume the payment of the mortgage debt, does not mean that the mortgagee can maintain an action at law upon this agreement between the mortgagor and the purchaser, but rests upon the' ground that the contract of the purchaser is a collateral stipulation obtained by the mortgagor, which by equitable subrogation inures to the benefit of the mortgagee. The mortgagee is said to stand on the rights of his debtor, and to be entitled to appropriate for his debt any security held by his debtor for its payment, and his remedy is restricted to the privilege of sub-rogation to his rights, and-will give him no rights against the purchaser which could not, under the contract of purchase, have been claimed by the original debtor. Accordingly .the mortgagee has been allowed to enforce the personal liability of such a purchaser only to the extent of the deficiency upon a foreclosure sale of the mortgaged premises, and only if the party to whom the purchaser’s agreement was given was himself personally liable for the payment of the mortgage debt. The doctrine of *592equity is that-when tbe grantee in a deed assumes the payment of the mortgage debt, he is to be regarded as the principal debtor, and the mortgagor occupies the position of a surety, as between, themselves, and the mortgagee-is permitted to resort to the grantee to recover the deficiency after applying the proceeds of a sale of the mortgaged premises, by the equitable' rule that the creditor is entitled to the benefit of all the collateral securities which his debtor has obtained to reinforce the principal obligation, though this right is strictly an equitable one, and its exercise at law has been refused. But the broad doctrine has since been laid down, that one for whose benefit a promise is made to another may maintain an action upon the promise, though he was not a party to the agreement or privy to the consideration thereof; and it was then held in unqualified terms that whoever has for a valuable consideration assumed and agreed to pay another’s debt may be sued dirpctlv by the creditor, and that a mortgagee or other encumbrancer may maintain a personal action against a jmrchaser from the owner of the equity of redemption who has agreed with his grantor to assume and pay off the encumbrance, if the party with whom the agreement was made was himself personally liable upon the mortgage debt, and that the purchaser who has made such an agreement cannot afterwards be released therefrom by his grantor, to whom it was made, without the consent of the creditor, to whose benefit it inures, if the latter has accepted it. The same rule will be applied to the case of any other encumbrance. But the mortgagee can simply hold such a purchaser to the performance of his agreement; he will not be subrogated to any other right against the purchaser. The development of this doctrine is’ doubtless an outgrowth of the law of substitution. It is sufficient to say that it has also been emphatically denied, and the court which laid down this proposition in its broadest terms (Lawrence v. Fox, 20 N. Y., 268) has refused to apply it to other somewhat similar cases, and has said that the iule is one which ought not to be extended.
The above principles are similarly stated by 'Mr. Sheldon, in his work on Subrogation, but, in the reference to the right of recovery at law on the contract, as having been made for the *593benefit of tbe several grantees, be classifies tbe courts and assigns tbis one to those of tbe class wbicb deny tbe doctrine of a recovery ex contractu, but sustain it upon tbe equitable principle of subrogation, citing in support of tbe statement Peacock v. Williams, 98 N. C., 324, to wbicb may be added Woodcock v. Bostic, 118 N. C., 828, and tbey seem to be aptly cited for tbat purpose.
We prefer, therefore, in view of tbe conflict of authority and tbe previous leaning of tbis Court towards tbe equitable right of 'subrogation, not to put our decision upon tbe disputed doctrine, but rather to adopt tbe other reason, wbicb is free from doubt, as its basis. If tbe question as to tbe strict contractual rights of tbe parties should ever arise, we may then, perhaps, consider' it in tbe light of some more recent decisions in tbis Court. We may well rest our decision upon tbe case of Woodcock v. Bostic, 118 N. C., 828, in wbicb tbe Court distinctly recognized tbis principle of equitable subrogation, as between tbe original vendor and purchaser, when the latter bad assumed to pay tbe encumbrance. Tbe note secured by tbe mortgage in tbat case bad been transferred to tbe plaintiff, as was tbe no.te in tbis case, so tbat tbe facts of tbe two cases are precisely tbe same. Tbe Court, it is true, refused to allow a recovery in tbat ease, because tbe equitable right- was not asked for; but we think, in tbat respect, it failed to apply the invariable rule under our Code, tbat relief is granted according to tbe facts pleaded, and not merely according to tbe prayer, as tbe facts stated warranted tbe granting of tbe relief. Tbe case, though, sufficiently settles tbe other point, but it does not go- beyond tbe first grantee in its scope. It cites Hayden v. Snow, 14 Fed., 70; Keller v. Ashford, 133 U. S., 610, to wbicb may be added 20 Am. and Eng. Enc. of Law (2 Ed.), 990; King v. Whittey, 10 Paige (N. Y.), 467; U. M. Insurance Co. v. Hanford, 143 U. S., 187; Henry v. Heggie, ante, 523, as to tbe equitable liability of tbe first grantee. Professor Minor, in bis great treatise on Eeal Property, says: “-If tbe assignee (of tbe land) does thus assume payment of tbe mortgage debt, be thereby becomes tbe principal debtor, and tbe original mortgagor is only liable subsidiarily as a surety. And while tbe mortgagee *594may continué to bold tbe mortgagor personally liable upon bis contract to pay tbe debt, notwithstanding tbe assumption of tbe mortgage by tbe purchaser of tbe land, be may also, it seems, bold tbe purchaser directly responsible, though be is not a party to tbe agreement between tbe mortgagor and tbe purchaser — a right based sometimes upon tbe principle that one may sue upon a contract to which be is not a party, if it be made for bis benefit, and sometimes upon tbe theory of tbe subrogation of tbe mortgagee to tbe rights of the mortgagor (tbe surety) against tbe purchaser (the principal debtor).” 1 Minor on Real Property, sec. 647. See, also, 2 Tiffany on Real Property, sec. 528; 20 A. and E. Enc. (2 Ed.), 992 et seq.; 3 Pomeroy Eq. Jur., secs. 1206, 1207.
But tbe doctrine reaches beyond this and extends to all tbe subsequent and successive grantees in tbe chain of assumptions, each forming a link in the chain which binds the last and the intervening purchasers of the equity of redemption, up bn their agreements'to assume, for tbe payment of tbe lien, not only to the first purchaser, but to his vendor and the mortgagee.
In our case, Miss Brown could hold Mrs. Purse (née Smith) upon her assumption; and since, as between the immediate parties, Miss Brown was principal and Misenheimer surety, Misen-heimer could not only hold Miss Brown on her assumption, but By virtue of the equitable doctrine of subrogation be could also take advantage of Miss Brown’s right of recourse to Mrs. Purse (née Smith); and since Misenheimer was legally bound to Rogers for the debt, Rogers could enforce all of Misen-heimer’s rights, including tbe right to proceed against both Miss Brown and Mrs. Purse (née Smith). But Rogers, in his turn, was bound by his obligation .to Hanie, so that Hanie could stand in Rogers’ shoes and enforce all of bis (Rogers’) rights, and could, therefore, take advantage of Rogers’ right to recover of Misen-heimer,. and so forth.
Now the plaintiff, as the holder in due course of the notes, can recover of Hanie, the maker of tbe notes, and can have tbe advantage of. all subsisting'obligations in the hands of Hanie securing the payment thereof. So that we reach the inevitable and logical conclusion that by reason of his equity, as creditor, *595to be subrogated to all tbe debtor’s rights, remedies, and securities, plaintiff can recover judgment against each and every one of tbe defendants. It was argued by counsel for tbe defendants, as we bave stated, tbat because there was no privity between Hanie and Misenheimer, there could be no recovery against Misenheimer, as there was no right of recourse to Misen-heimer in favor of Hanie to which plaintiff could be subrogated. The court below, in sustaining this contention, misconceived the theory and scope of the doctrine of subrogation. If Hanie had, strictly speaking, and primarily, no cause of action against Misenheimer, there was in favor of Hanie the equity to be sub-rogated to all the rights, remedies, and securities of. Rogers, and among them was the right to go against Misenheimer. There is not lacking ample authority for the position here taken. 27 Cyc., 1355, which says: “If mortgaged property passes through the hands of successive grantees, each of whom assumes the mortgage, the personal liability of the last holder inures to the benefit of the mortgagee, and may be enforced by him.”
The cases about'to be cited all recognize and apply the rule that the mortgagee in such a case, by virtue of the equitable principle of subrogation,, can recover of the vendee of the mortgagor, or his successors, who have assumed like obligations to their vendors, an amount sufficient to discharge the encumbrance. Biddle v. Pugh, 59 N. J. Eq., 480; Wager v. Link, 134 N. Y., 122; Fisher v. White, 94 Va., 233; Hospital of St. Barnabas, 27 N. J. Eq., 650; Miller v. Thompson, 34 Mich., 10; Osborne v. Cabell, 77 Va., 462; Hopkins v. Warner, 109 Cal., 136; Crowell v. Currier, 28 N. J. Eq., 152; Stover v. Tompkins, 51 N. W. (Neb.), 1040. This action was not brought by the mortgagee who held the encumbrance on the land, but his assignee of the notes secured thereby. But this should make no difference in the result, as it is familiar doctrine that the assignee of a note secured by a mortgage is entitled to the full benefit of the mortgage. Jones v. Ashford, 79 N. C., 172; Hyman v. Devereux, 63 N. C., 624. It may not be amiss to add that when the complaint in the case of Woodcock v. Bostic was amended in the court below so as to set up the equity of subro-gation, and the case, after a trial there, was again brought to *596this Court,, it affirmed a judgment in favor of tbe plaintiff. Tbe notes secured by tbe mortgage were, in tbat case, as it appears, assigned to- tbe plaintiff. So tbat tbe case is a direct decision on tbe question as to tbe first grantee, and tbe doctrine bas, by tbe great weight of authority, as we have seen, been extended to 'subsequent grantees. We believe tbat this decision, apart from tbe direct authorities sustaining its basic principle, which is greatly favored by tbe law, is a fair and just interpretation of tbe meaning and intention of tbe parties and is tbe proper deduction to be made'from tbe form and nature of tbe several transactions. Tbe equity of subrogation springs naturally out of tbe two other equities, contribution and exoneration, and is, in fact, one of tbe means by which those equities are enforced. It is eminently calculated to do exact justice between persons who are bound for tbe performance of tbe same duty and obligation, and is one;,, therefore, which is much encouraged and protected. It was called into existence for tbe purpose of enabling a party secondarily liable to reap tbe benefit of any securities or remedies which tbe creditor may bold as against tbe principal debtor, and.by tbe use of which the party xoaying may thus be made whole. It may be used to enforce tbe equity of exoneration as against tbe principal debtor, or of contribution as against others who are in tbe same rank. Bispham on Equity (6 Ed.), sec. 335. Tbe doctrine is far-reaching and bas been so extended tbat a person standing in tbe relation of‘a surety reaps its benefit and is thereby entitled to have all of tbe principal’s, means of indemnity, including tbe privilege of' substitution to tbe principal’s or debtor’s claim to indemnity or repayment from others, including all remedies and securities held by him. Sheldon on Subrogation, sec. 100; Hobson v. Bass, L. R. 6 Ch., 792; Rodenbarger v. Bramblett, 78 Ind., 213. If one surety takes a security from the principal for bis own indemnity, it will inure to tbe benefit of all tbe sureties by tbe operation of this rule, because equality is equity. Bispham on Equity (6 Ed.), sec. 337, p. 454. We bold, therefore, tbat tbe court bas incorrectly applied tbe law to tbe facts of this case.
It will not be contended tbat when tbe grantees accepted tbe several deeds they did not each become bound by its covenants, *597tbe same as if they bad jointly executed tbem witb tbe grantors, and even tbougb tbey were deeds poll and not deeds indented. 20 Am. and Eng. Enc. of Law (2 Ed.), 990; King v. Whitley, 10 Paige (N. Y.), 467, and Henry v. Heggie, ante, 523.
Before closing tbis opinion, we must acknowledge our indebtedness 'to Mr. Taliaferro for bis learned brief and able argument. His research bas greatly enlightened us and facilitated our investigation of tbe subject.
Error.