Pickens County Bank, by and through E. E. Gormley, superintendent of banks, brought its petition in the superior court against Jasper School District, a local school district of said county. The petition was brought in two counts. The first count was on certain notes alleged to have been executed by the board of trustees of the school district for money loaned by the plaintiff. In the second count the execution of the notes was again alleged, and the further allegation was made that the defendants had refused payment of the notes “because of certain alleged technicalities in connection with the execution thereof,” and that if petitioner has no right to recover on the notes it is “entitled to recover from the defendant the principal amounts as specified in said notes, for the reason . . that the sums of money . . described in said notes were . . used by said defendant . . in payment and discharge of .liabilities legally incurred by the trustees in operating the schools of such district, and in defraying the lawful current expense of 'operating schools in such district;” that by reason of these facts the defendant has taken to its use money which in justice and fairness and in equity and good conscience belongs to plaintiff; that the plaintiff advanced said sums to the defendant “in good faith and in the belief that the defendant had a legal right to borrow same and on the expectation that the same was to be repaid; and defendant *757having secured said sums of money on its promise to repay, and having used said sums of money in' defraying its lawful expenses, it is in equity and good conscience bound to repay same to plaintiff, with lawful interest from the date of receipt of said several sums of money as shown by said notes, and plaintiff is entitled to be subrogated to all rights of the parties to whom said money was paid, and defendant is indebted to plaintiff in said sums of $8092.” The prayers were for process, and, “in the event that the court should find that said notes are not legal obligations of said defendant, then and in that event that it should have a judgment against the said defendant for the principal sum of $8092 as for money had and received, said amounts being shown and designated as the amount specified in said notes above ■ described, together with lawful interest thereon.55 There was no prayer that' the plaintiff be subrogated to the rights of the parties to whom the money was paid, nor was there a prayer for general relief. By amendment the plaintiff set out to whom and for what purposes the money loaned was paid by the defendant. TJpon a hearing on demurrers to the petition, the court passed an order overruling certain of the demurrers and sustaining others. The defendant excepted to that portion of the order overruling demurrers; and the plaintiff filed a cross-bill of exceptions assigning error on that portion of the order sustaining demurrers. The ease was transmitted to the Court of Appeals, and by that court transferred to this court on the ground that the Court of Appeals did not have jurisdiction “to determine the purely equitable question as to whether the demurrer to the count setting up a claim based solely upon Tegal5 subrogation was properly overruled.”
This court is of the opinion that the second count of the petition, properly construed in accordance with previous decisions of this court, is not one seeking to set up a claim “based solely upon Tegal5 subrogation,55 but is one seeking a money judgment only in an action at law as for money had and received. An action for money had and received was, under the common law, one of the common counts of general assumpsit, and brother to the other money counts, money lent and money paid. 57 Am. D. 544, note. The action of general assumpsit is of an equitable character, and had its origin in a conception of a tort liability primarily based upon the element of deceit, by which one at*758tempted to enrich himself at the expense of another, from which ex debito justitise an implied promise was evolved. Whitcomb v. Brant, 90 N. J. L. 245 (100 Atl. 175, L. R. A. 1917D, 609). It was soon transformed into an action of contract, becoming after-wards a remedy where there was neither tort nor contract. Philpott v. Superior Ct., 1 Cal. (2d) 512 (36 Pac. (2d) 635, 95 A. L. R. 990). “And it is now maintained in many cases which its principles do not comprehend, and where Actions and intendments are resorted to, to fit the actual causa of action to the theory of the remedy. It is thus sanctioned where there is no actual assumpsit, no real contract, but where some duty is deemed sufficient to justify the court in imputing a promise to perform it, and hence in bending the transaction to the form of action.” (Italics ours.) 4 Am. Jur. 495, and cit. The action of money had and received, as a form of assumpsit, was invented by the common-law judges to permit litigants to secure relief from the narrower restrictions of the common-law procedure which afforded no remedy in too many cases of merit. Heywood v. Northern Assurance Co., 133 Minn. 360 (138 N. W. 632, Ann. Cas. 1918D, 241); Bosworth v. Wolfe, 146 Wash. 615 (264 Pac. 413, 56 A. L. R. 1117). An action-for money had and received is founded upon the equitable principle that no one ought unjustly to enrich himself at the expense of another, and is maintainable in all cases where one has received money under such circumstances that in equity and good conscience he ought not to retain it, and ex aequo et bono it belongs to another. Merchants Bank of Macon v. Rawls, 7 Ga. 191 (50 Am. D. 394); Alexander v. Coyne, 143 Ga. 696 (85 S. E. 831, L. R. A. 1916D, 1039). Thus an action for money had and received is a substitute for a suit in equity (Culbreath v. Culbreath, 7 Ga. 64, 50 Am. D. 375), and, while founded on causes of action arising out of application of equitable principles, is an action at law by reason of its origin as a mode of action in the common-law courts. Culbreath v. Culbreath, supra.
Does the fact that the cause of action as set forth in an action for money had and received arises out of circumstances which give rise also to a right of subrogation make the action for money had and received one cognizable only in a court of equity? Subrogation is the substitution of another person in the place of the *759creditor whose obligation is paid, so that the person in whose favor it is exercised succeeds to all the rights of the creditor. It is of equitable origin, being founded upon the dictates of refined justice, and its basis is the doing of complete, essential, and perfect justice between the parties, and its object is the prevention of injustice. Wilkins v. Gibson, 113 Ga. 31, 42 (38 S. E. 374, 84 Am. St. R. 204); Cornelia Bank v. First National Bank of Quitman, 170 Ga. 747 (154 S. E. 234); Lee v. Holman, 182 Ga. 559 (186 S. E. 189). It is the mode which equity adopts to compel the ultimate payment of a debt by one who in equity, justice, and good conscience, ought to pay it. 60 C. J. 698; Sheldon on Subrogation, 2, n. 10, and cit. Subrogation originated in equity; and in the absence of statute the right to subrogation, or the right to be subrogated, that is placed in the shoes of another, is not enforceable as such in an action at law. Thomason v. Wade, 72 Ga. 160, Hull v. Myers, 90 Ga. 674 (16 S. E. 653); Sherling v. Long, 122 Ga. 797 (50 S. E. 935); Fender v. Fender, 30 Ga. App. 319 (117 S. E. 335). The reasons underlying the adoption of the doctrine of subrogation by courts of equity are to a great extent substantially the same as the reasons underlying the adoption o£ the remedy of money had and received by courts of law. Subrogation is not, strictly speaking, a remedy, but is rather an equitable principle engendering a cause of action enforceable in equity. Money had and received is an action or remedy at law for the enforcement of legal as contradistinguished from equitable rights, although both arise out of equitable principles. The same facts and circumstances may give rise to a cause' of action enforceable as a legal right in a court of law as for money had and received, or as an equitable right to subrogation enforceable in a court of equity. In the one a judgment for money only is sought, based upon the duty to repay which the circumstances imply; in the other the substitution to the rights of the creditor whose debt has been paid is the relief sought. While a money judgment may be the final goal in the latter instance, the mode of arriving to that end is different in the two cases. As was said in Offer v. Superior Court, 194 Cal. 114 (228 Pac. 11) : “The development of subrogation is closely analogous to several other modes of remedy. The question often arises whether one who has suffered by being held liable for the tort or breach of contract of another *760should seek his remedy by an action founded on an express promise of indemnity, if such there was, or on the implied assumpsit raised by his payment of the obligation of the other, or upon the theory of subrogation. In some cases the claimant may have taken an assignment of the demand he has paid; he may have an express contract of indemnity, or an implied assumpsit to rest upon, and yet perhaps may have an election to proceed on the theory of subrogation.” That there is a distinction in enforcing a right of action for a money demand, and a right to subrogation arising out of the same transaction, was recognized in Krotine v. Link, 36 Ohio App. 537 (173 N. E. 443).
While the action for money had and received is often referred to as an “equitable action” (Butts County v. Jackson Banking Co., 129 Ga. 801, 60 S. E. 149, 15 L. R. A. (N. S.) 567, 121 Am. St. R. 244); McCay v. Barber, 37 Ga. 423, 424; Whitehead v. Peck, 1 Ga. 140), it is nevertheless an action at law (Brightwell v. Oglethorpe Telephone Co., 176 Ga. 65, 166 S. E. 640); and even though the transaction out of which arises the right to an “equitable action” for money had and received may also give rise to a right of subrogation, the claimant may proceed upon his legal right for a recovery of the sums received by the defendant under such circumstances that in equity and good conscience the defendant ought not to retain it, and ex aequo et bono it belongs to the claimant. Under the ruling in Butts County v. Jackson Banking Co., supra; (3), that “An action for money had and received may be maintained by one who has loaned money to a county, and which has been used by it to discharge a legally incurred liability for a current expense, although the governing official or officials of a county have no authority to borrow the money or to give a note therefor,” it is not necessary that the right to subrogation be established before a recovery can be had in an action for money had and received. The remedy in equity to enforce the right to subrogation, and the remedy at law for money had and received are separate and distinct remedies, though they may $rise out of the same transaction. See Thomas v. Lester, 166 Ga. 274 (5, 6) (142 S. E. 870). The only basis on which the second count of the petition in the instant case could be held to be one seeking the right to subrogation is by reason of the allegation therein that the “plaintiff is entitled to be subrogated *761to all rights of the parties to whom said money was paid.” This, however, does not make it an equity case. The only relief sought is a recovery of a judgment for money had and received. To make a case in equity the allegations of the petition must be applicable to the equitable relief prayed for, and there must be a prayer either for the specific relief, or for general relief; and even though the allegations of the petition are such as to authorize the grant of equitable relief under suitable prayers therefor, yet if there be no prayer for the specific equitable relief ox for general relief, the case presented is not an equity case. Copeland v. Cheney, 116 Ga. 685 (43 S. E. 59); Cooper v. Coral Gables Inc., 45 Ga. App. 290 (3) (164 S. E. 227). Whether a petition is based upon an equitable or a legal- cause of action depends upon the nature of the relief sought, as shown by the prayers, which indicate whether the alleged cause of action is intended by the pleader as founded upon an equitable or a legal' right. Steed v. Savage, 115 Ga. 97 (41 S. E. 292). See also Fowler v. Davis, 120 Ga. 442 (47 S. E. 951); Pound v. Smith, 146 Ga. 431 (91 S. E. 405); Bernstein v. Fagelson, 166 Ga. 281, 287 (142 S. E. 862); Burgess v. Ohio National Life Ins. Co., 177 Ga. 48 (169 S. E. 364); Jones v. Lawman, 184 Ga. 25 (190 S. E. 607); Rucker v. Mobley, 44 Ga. App. 705 (162 S. E. 851); Smith v. Nussbaum, 43 Ga. App. 103 (157 S. E. 877). It is true that in the instant ease, whether the prayers be for legal or equitable relief, the final result would be the same — a money judgment. However, the theory on which such a money judgment is obtained is different in law and in equity. In law it is for money had and received, based upon a legal right evolved from equitable principles. In equity it is upon the obligations held by the creditors whose debts were paid by the claimant by an equitable substitution of the claimant for such creditors. There is no prayer in the instant case that the money judgment be obtained through the latter course; but the prayer itself specifies that it is sought through the former. Therefore, under the rulings in the above decisions, we are of the opinion that the second count of the petition in the instant case is one seeking recovery of a money judgment in an action at law, and that it is not an equity case within the meaning of the constitutional provision (Code, § 2-3005) stating that the Supreme Court has exclusive jurisdiction of "equity cases.”
Remanded to the Court of Appeals.
All the Justices concur.