delivered the opinion of the court.
This is an action to recover the possession of real property. Frank W. Hale is the common source of title. The plaintiff claims title, and also possession, as the sole devisee under his will; the defendant Hamilton (the other defendants being his tenants) as the purchaser at a foreclosure sale under a power of sale in a mortgage given by Hale several years before his death. The trial court found the issues in favor of the defendant, and rendered judgment accordingly.
The appellant-questions certain rulings of the trial court upon important and difficult legal propositions, but in the view we take of the case only one point need be determined, for *265our resolution thereof in her favor is decisive of the controversy. At the close of the plaintiff’s case her evidence, showing death of Hale and the probate of his will devising the property to her, was sufficient to entitle her to a judgment; and unless the defendant overcame the case as made, the judgment of the court below in his favor should be set aside.
At the time of the attempted foreclosure and sale at which the appellee Hamilton purchased, there was in force in this state the following statute:
“ Creditors of any estate whose debts or claims are secured by mortgage or deed of trust on real estate, or by chattel mortgage or other security on personal property, shall not be allowed to foreclose such mortgage, deed of trust, chattel mortgage or other security, within one year from the death of the testator or intestate, unless by the permission of the county court having charge of the estate, and in no event until-their debts or claims have been first proved and allowed by such court.” Session Laws, 1889, p. 474.
This act was an amendment of a prior law (see Session Laws of 1885, p. 895, sec. 8), and the latter act includes chattel mortgages, or other security upon personal property (which the former did not), as well as mortgages or deeds of trust upon real estate. Whether the prior or the later law governs this case is immaterial, for they are substantially the same, so far as applicable to the question before us. In the second defense of the answer, in which is set forth the attempted foreclosure and sale by virtue of the power of sale contained in the mortgage, the defendant, Hamilton, while alleging strict and full compliance with the specified terms of the mortgage relating to the execution of the power of sale, failed to aver that the debt secured by the mortgage had been presented to, or allowed by, the county court. It is true that in the first defense -of the answer there was a denial of the death of Hale and the probate of his will in the county court of Arapahoe county, as averred in the complaint. In the second defense, however, these allegations were admitted by a failure to deny them. Each defense must be complete *266in itself, without reference to any other separate defense of the answer. The case, then, so far as concerned the second defense was this:
The mortgagee, after the death of the mortgagor, and while the estate of the latter was in charge of the county court of Arapahoe county, proceeded under the power of sale inserted in the mortgage to foreclose and sell the mortgaged property, without presenting to the county court for allowance the note which the mortgage secured. The object of this statute was to protect the estate from fraudulent claims, and to remedy the evils resulting from sales made by creditors so soon after the death of the owner of the property that his personal representatives had no opportunity to advise themselves of the condition of the estate, or in any way to provide for the payment of claims. This statute puts it beyond the power even of the personal representative to consent to the foreclosure and sale contrary to its provisions; and the sale in this instance having been made in direct violation of the statute, the attempted foreclosure was void. Reid v. Sullivan, 20 Colo. 498; Belmont M. & M. Co. v. Costigan, 21 Colo. 471; Sullivan v. Sheets, 22 Colo. 153.
The provisions of the statute must be read into the mortgage. It annexes, or adds, to the conditions and terms which that instrument contains, the further one that the mortgage shall not be foreclosed until the debt secured is proved or allowed in the proper court. A defense, therefore, under a state of facts like this at bar, setting up a title, or right of possession, based upon a foreclosure and sale, which fails to state a compliance with this statute is insufficient in law.
Section 261 of the code provides that: “A mortgage of real property shall not be deemed a conveyance, whatever its terms, so as to enable the owner of the mortgage to recover possession of the real property without foreclosure and sale * * * ” Now whether, as in a mortgage not carrying a power of sale, the instrument must be foreclosed in a court of equity, or, as in a power of sale mortgage, the foreclosure, as contended by defendant, may be made out of court by the *267mortgagee himself in compliance with the terms of the power, the right of possession, in either event, belongs to the mortgagor, until a valid foreclosure. Even though the latter form of conveyance transfers the legal title, the one who holds such title is not, for that reason alone, entitled to possession.
Certainly, no more can be claimed for a void foreclosure under a power of sale mortgage than under a trust deed, and if in such sale, as contended by the appellee, the legal title passes to the grantee under both forms of conveyance, nevertheless a void sale thereunder (if effectual for any purpose) passes to the purchaser that title subject to the same rights which the grantor had as against his immediate grantee before a valid sale and foreclosure was had. In other words, the purchaser at most gets only the mortgagee’s rights, and they are subject to whatever rights the mortgagor retains prior to valid foreclosure. As was said in Stevens v. Clay, 17 Colo. 489, 492 : “ But a sale and deed, except in strict compliance with the power specified, is of no effect whatever so far as the trustor’s equitable estate is concerned.. If the trustee, in disobedience of the trust conditions, by deed transfer the legal title, his grantee takes only the trustee’s interest. He steps into the trustee’s shoes, so to speak, and holds subject to all reserved rights of the trustor.” And in Belmont v. Costigan, supra, it is said at page 479: “ The right of possession remains with the grantor until a sale for default is made,” which, of course, means a valid sale.
In Bent-Otero Imp. Co. v. Whitehead, 25 Colo. 854, the court, speaking by Mr. Justice Goddard, said:
“ Aside from these objections ” (matters theretofore alluded to) “ the assignments of error present but one question, and that is whether a trustee named in a deed of trust, wherein the power of sale is conditioned upon the request of the beneficiary, can sell the land, and convey to the purchaser a good title, without such request, or without any circumstance from which the purchaser could infer such request on his part. The powers of a trustee depend entirely *268■upon the terms of the instrument appointing him, and no power is conferred unless expressed in the writing. Such request, therefore, becomes a condition precedent to his power to sell, and since the rule of caveat emptor applies to trustee’s sales, the purchaser is bound to take notice that all matters in pais upon the existence of which the trustee’s power to act depends have been complied with. * * * We think it is clear, under the established facts in this case, and the doctrine laid down by the uniform current of authority, that the action of the trustee in making the sale of the trust property was unwarranted, and appellant acquired no title thereunder.”
While conceding that the doctrine of these cases is sound if confined to equity, the defendant contends that to permit in this, a law action, an inquiry into the regularity or validity of the proceedings under the power of sale would be to reverse the practice hitherto obtaining in this state and elsewhere in an action for the recovery of real property under the code; and, moreover, that plaintiff’s contention in this behalf ignores the distinction between the rights óf a mere equitable mortgagee or lienor, and a purchaser under a valid power authorizing the sale of the premises in fee simple.
Plaintiff was not obliged to file a bill to redeem. She had the right to insist that the sale, being contrary to the terms of the statute, was void, and she might consider the possession obtained by the purchaser thereat, he being charged with notice of the invalid sale, the same as if the mortgagee before default had wrongfully obtained possession. In such a case, where the trustee, or the beneficiary of the trust deed, or the mortgagee in a mortgage containing a power of sale, wrongfully obtains possession without a valid foreclosure and sale, it has been held that the grantor or mortgagor, having the legal right to possession, may recover in ejectment. 1 Jones on Mortgages (5th ed.), § 36; Newton v. McKay, 30 Mich. 380; 10 Am. & Eng. Ency. of Law (2d ed.), 482.
And even in the federal courts where the distinction between law and equity is rigidly maintained, it has been held *269that a plaintiff, though not holding the legal title, but only a contract with the legal owner which while executory gives the right of possession, and which, when fully executed, will give him the legal title, may maintain ejectment because he has the legal right to possession. Melenthin v. Keith, 17 Fed. Rep. 583.
But appellant says that this court, in Wells v. Caywood, 3 Colo. 487, has decided that, in order to entitle a purchaser at a trustee’s sale to maintain ejectment, it does not devolve upon him to show that his grantor had complied with the conditions prescribed in the deed of trust. The decision was prior to the adoption of our code of civil procedure, and the title of the purchaser, though a defeasible one, was held to be a legal title, and, at common law, the legal title prevailed in ejectment.
At common law it has, however, been held competent in an action of ejectment to show that a conveyance relied upon by one of the parties was made with intent to defraud creditors (Knox v. McFarran, 4 Colo. 586; 10 Am. & Eng. Ency. of Law (2d ed. ), 520, 521, note 1) ; and that a void deed might be rejected as a nullity, though in order to have the same canceled a resort to equity was necessary. Salsbury v. Ellison, 7 Colo. 167; Tyler on Ejectment, 70-75.
So, also, in an action under the code for the recovery of the possession of real estate, the incapacity of the grantor of the deed relied upon as a defense may be shown. Elder v. Schumacher, 18 Colo. 433.
The deed of the defendant being void, it would be treated as a nullity in this action even before our code of procedure was adopted. But if it be conceded, as defendant claims, that the mortgagee’s deed in this instance transferred to the purchaser the naked legal title, does it necessarily follow that the latter’s light to possession cannot be questioned by the mortgagor (or his devisee) in an action to recover possession ? The question then is whether, in an action under our code, to recover the possession of real property, the plaintiff can succeed on an equitable title. It is not true *270that the mere legal title always prevails. The right of possession must he combined with it. 10 Am. & Eng. Ency. of Law (2d ed.), 494, and cases supra; Covert v. Morrison, 49 Mich. 135. We have no action of ejectment in this state. But one form of civil action is recognized, and if the complaint states facts constituting a cause of action, and is sustained by the proof, appropriate relief will be granted, irrespective of the prayer of the complaint, and without regard to the form in which the action is cast. The cases above cited from our own court establish the doctrine that where a trustee unlawfully conveys the legal title, his grantee takes subject to the truster’s rights, one of which is the right of possession until a valid sale, and the same rule should apply to the case of an unlawful sale under a mortgage, even though the mortgagee has the legal title.
In so-called legal actions equitable- defenses are permitted under our code; sec. 59 ; and if, as in this case, the defendant sets up a title based upon an alleged valid foreclosure and sale under a mortgage, we see no reason why the plaintiff may not show that the defendant has no right to possession, because the sale on which he relies is void.
Furthermore, let us suppose that the purchaser Hamilton was the plaintiff, and had brought suit against Lewis, the devisee, to recover possession, and, as here, relied upon the title secured at the foreclosure sale; could not Lewis, by demurrer, if the invalidity appeared on the face of the complaint, or, if not, then in the answer, set up that the title of plaintiff was void, because the statute governing such sales had been directly violated; and would not the defense, if true, prevail even though plaintiff had the naked legal title ? Granting that the same would be an equitable defense, what difference, in principle, is there between the supposed case, and the one at bar? Here Lewis is the plaintiff, and the title pleaded by Hamilton as a defense is one upon which he could not recover as a plaintiff. In either case, Hamilton has not the right of possession, because it depends solely upon, a foreclosure and sale forbidden by the statute; and Lewis *271has the legal right to possession, for that was reserved until a valid sale, and that has never occurred. It seems absurd to say that a title with which a party may succeed as a defendant, and retain possession, cannot be used by him, as a plaintiff, out of, and seeking to obtain, possession. It ought to be that a title which may be successfully pleaded defensively should be attended with like results when pleaded affirmatively.
In the case at bar, the act of the defendant in pleading and relying on a void title injected into the cause an issue, whether it be legal or equitable, which the plaintiff was entitled to meet in this action. In a jurisdiction which administers in the same action legal and equitable relief, it seems idle to require her first to get a decree declaring the mortgagee’s deed void before she could plead the invalidity of the deed when set up against her as the defendant’s sole right to possession.
It may be that the greater number of authorities is against this position; but we think that the true spirit, as well as the letter of our code, permits a plaintiff who has an equitable title, or is the equitable owner of real property with a legal right to possession, to maintain an action to recover its possession.
In Kansas, under a provision of the code, the holder of an equitable title may maintain the action. K. P. R. R. Co. v. McBratney, 12 Kan. 9. In Phillips v. Gorham, 17 N. Y. 270, the court of appeals of New York under code provisions like our own recognized the principle which we hold governs this case. The opinion is an instructive one, and is in harmony with our views. See, also, to the same effect, Murray, Ferris & Co. v. Blackledge, 71 N. C. 492, Pomeroy’s Rem. & Rem. Rights, §§ 98-103, 10 Am. & Eng. Ency. of Law (2d ed.), 532 et seq., and cases cited, Pomeroy’s Code Remedies (3d ed.), § 90 et seq., §§ 98-103.
In his work on Code Pleading (3d ed.), § 351, Judge Bliss does not wholly coincide with the conclusion of Mr. Pomeroy, yet says, that the statutory action for the recovery of the *272possession of real property differs from the old ejectment, and that no man can be turned out who has a right to stay in, no matter who has the legal title.
We conclude that, under our code, which permits of equitable defenses in actions for the recovery of the possession of real property — and therefore recognizes the right of an equitable owner to the possession, even though another has the legal title — -that the equitable owner, who, as such, has also the legal right to possession, may, as a plaintiff, recover thereon from the defendant holding the legal title.
The judgment is reversed and the cause remanded.
Reversed.