Thomson, J.,
delivered tire opinion of the court.
This is an action brought by the appellees for the enforcement of certain mechanics’ liens against A. S. Tooke, the owner of the premises upon which the liens were claimed. A number of persons were made parties defendant, as claiming some interests in, or liens upon, the premises. The Holmes Hardware Company, defendants, answered, setting up, by way of cross complaint, the facts constituting a lien in their favor for $421.54, alleging that it was prior and superior to that claimed by the plaintiffs, and praying its enforcement against the premises. The defendant, Louis Florman, filed his cross complaint, claiming a lien for $967,40, superior to the liens of all the other parties, and praying judgment for its enforcement. The cross complaint of the defendants, Morgan & Geiser, averred a lien in their favor for $1,014.05, having priority over those claimed by the plaintiffs, and asked its enforcement against the property of Tooke. The defendant, T. A. Sloane, alleged that on January 30, 1891, the defendant Tooke, being the owner of the property against which the several liens were claimed, conveyed the premises to him as trustee, with the usual power of sale, to secure the payment of a promissory note for $2,500, *108made by Tooke to the Pueblo Savings Bank; that the deed was duly recorded on the day of its execution; and that it was a first and prior lien upon the premises against all the parties to the action, and prajmd judgment accordingly. Afterwards, by leave of court, the plaintiffs filed a supplemental complaint, setting forth that defendant Sloane, as trustee, after the filing of his answer and cross complaint, at the request of H. J. Fitch, the legal owner and holder of the note which the trust deed was given to secure, in pursuance of the provisions of the deed, advertised and sold the property conveyed by it, for $4,250 ; that Fitch being the highest and best bidder, became the purchaser ; that the note, interest and cost of executing the trust, amounted to $8,050 ; and that after the payment of this sum there remained in the hands of Sloane, as trustee, a surplus of- $1,200; also, that after the filing by Morgan & Geiser, and the Holmes Hardware Company of their cross complaints, Fitch had become the owner of their lien claims. The supplemental complaint-further averred the service upon Sloane, immediately after the sale, of a notice that the surplus in his hands was subject to the liens of the plaintiffs, directing him to retain it in his possession to abide the order of the court; and prayed that Fitch be made a party defendant, and that the surplus be applied in payment of the plaintiffs’ claims. Fitch, having been made a defendant, by leave of court filed his answer and cross complaint in the cause. In his cross complaint he set forth the trust deed, his ownership of the note which the deed was given to secure, and the sale of the property in pursuance of the terms of the deed, its purchase by him, and the execution by the trustee of a deed conveying the mortgaged premises to him. The cross complaint further showed that the liens of the defendants, Morgan & Geiser, the Holmes Hardware Company and Louis Florman, were prior and paramount to the liens and claims of the plaintiffs, and also to the trust deed to Sloane, and that for the purpose of protecting his security upon the premises by virtue of his ownership of the note, he paid off, satisfied and discharged the *109claims of Morgan & Geiser, the Holmes Hardware Company, and Louis Florman; that the claims of Morgan & Geiser and the Holmes Hardware Company were paid after the filing of their answers and cross complaints, and prior to the sale; that the claim of Louis Florman was paid after the sale; and that the amount paid Morgan & Geiser and the Holmes Hardware Company was greater than the surplus in the hands of the trustee, and was justly due to them upon their claims. The cross complaint concluded with a prayer for an order that the surplus fund in the trustee’s hands be awarded and paid to him.
The plaintiffs demurred to the cross complaint on the ground that it did not state facts sufficient to entitle the defendant, Fitch, to the relief sought. The demurrer was sustained, and the cause proceeded to trial upon the remaining pleadings. The court found from the evidence that the plaintiffs’ liens upon the premises were valid, but junior and subordinate to the trust deed to Sloane, and to the liens of Morgan & Geiser, the Holmes Hardware Company, and Louis Florman, whose several claims and liens were prior, superior and paramount, not only to the liens of the plaintiffs, but also to the trust deed to Sloane; and adjudged that by virtue of the payments to them by Fitch, the premises were free and clear of their lien claims, and that the surplus fund of $1,200 be paid to the plaintiffs. The defendant Fitch appealed, and assigns for error the sustaining of the demurrer, and the awarding of the surplus to the plaintiffs.
The right of a mortgage creditor to pay off a prior incumbrance upon the mortgaged premises for the purpose of protecting his security, and, upon foreclosure, to a reimbursement from the proceeds of the sale, of the amount so paid, is established by a continuous and uniform line of authority. In such case he becomes invested with the rights of the holder of the prior lien, and is entitled to have it enforced for his benefit upon the foreclosure of his own mortgage. As a general proposition this is conceded by counsel for the appellees, but they contend that mechanics’ liens do not belong to the *110class of incumbrances to which the rule is applicable. The adjudications have been, for the most part, in cases where the prior liens discharged were those of taxes, mortgages or judgments; and counsel seek to distinguish these from mechanics’ liens on the ground that the former are full-fledged incumbrances, whereas the latter, until they are established by judgment, are inchoate merely, and may never ripen into valid liens; and that while they so remain it cannot be said that their payment by a junior incumbrancer is necessary for the protection of his security. IFe confess our inability to appreciate the attempted distinction. It is true that what purports to be a mechanic’s lien may be so defective that it is not alien, and is incapable of enforcement; and it is also true that a lien originally valid may be lost by a failure to bring suit upon it within the time limited by the statute. The purchaser of such a lien assumes the risk of its validity; he succeeds only to the rights of the original owner; he is charged with knowledge, not only of its inherent defects, but of any extrinsic facts which would operate to defeat it; the burden of establishing it is upon him, and he is held to the same diligence in enforcing it that is required of the first claimant. But a lien which is just, and is acquired in conformity with the statute, is an incumbrance upon the land, and so remains until its removal by payment, or until it is lost by delay; and the effect of its enforcement is the same as that of the foreclosure of a mortgage. The reason why a mortgagee is permitted to pay off an antecedent incumbrance, and succeed by subrogation to the rights of the holder, is that such prior lien may result in divesting the title upon which his security depends, thus destroying the security; and the principle is applicable to any incumbrance which may have that effect. A mechanic’s lien, valid in its inception, and prior in time to that of a mortgagee is, while the right to enforce it exists, as much a menace to the integrity of his security as an older unforeclosed mortgage, or an outstanding judgment upon which execution has not been issued; and in equity he is entitled to the same pro*111tection against the mechanic’s lien as against the mortgage or judgment.
But in order that the rights of a prior incumbrancer may descend to him so as to entitle him to a reimbursement out of the proceeds of a sale under his mortgage, the lien claim must be paid off before the sale. If at the time of the sale it is still outstanding, the purchaser buys subject to it, and if he subsequently pays the claim, the lien becomes merged in his title and extinguished. Scott v. Shy, 58 Mo. 478; Byington v. Fountain, 61 Iowa, 512.
In this case the demand of Louis Florman was paid after the sale, and the appellant is, therefore, not entitled to any relief on account of that claim. But the facts in connection with the lien claims of Morgan & Geiser, and the Holmes Hardware Compaq', and the rights of appellant in relation to these claims, are altogether different. Proceedings were pending for the enforcement of the liens, the claimants were in court with cross complaints to procure a decree for the sale of the property to satisfy their claims; and it was while they were pressing their suits and before the foreclosure of his deed of trust, that the appellant made the payments to them for which he seeks indemnity. As to these claims, he succeeded to the rights of the lien claimants, and his right to a reimbursement from the proceeds of the sale is clear, if the liens were valid and subsisting incumbrances, and could have been enforced against the property. The question of the existence and validity of the liens was adjudicated at the hearing. The claimants filed cross complaints in which all the facts necessary to the enforcement of their liens were set forth. After having acquired their interests, instead of causing himself to be substituted for them in the action, he suffered the cause to proceed in their names upon the pleadings which they had filed, as he had the light to do. Section 15, Civil Code.
Upon the evidence adduced, the court found for the cross complainants, that their liens were superior and paramount to those of the plaintiffs, and also to the trust deed to Sloane. *112This finding is conclusive of the validity and rank of the liens, and the only questions in the case which were left undetermined were the sums paid by the appellant to these lien claimants, and the time when the payments were made. The amount of the claims was in excess of the surplus fund in the hands of the trustee, but the appellant is entitled to indemnity, in so far as the surplus is sufficient for the purpose, only to the extent of his actual payments. The court should have overruled the demurrer, permitted the plaintiffs to answer the cross complaint, and determined these questions together with the other questions in the case. Every other question is finally settled by the judgment and decree, which will be reversed, with instructions to the court below to overrule the demurrer, and permit the plaintiffs, if they so desire, to put the fact and amount of the payments, and the time when they were made, in issue by answer; and if it shall be found that they were made, as alleged in appellant’s cross complaint, before the sale under the deed of trust, and that the whole amount paid is equal to the surplus fund, to adjudge this fund to the appellant; or, in case of a failure or refusal of the appellees to answer, to render the same judgment as by a default. If, however, upon answer filed and hearing had, it shall appear that the sum so paid is less than the surplus, then judgment shall be rendered in favor of Fitch for that amount only, and the residue shall be awarded to the plaintiffs.
Reversed.