The opinion of the court was delivered by
Valentine, J.:This was an action brought in the district court of Wyandotte county on May 11, 1889, by Robert Garrett and D. J. Griest against Thomas B. Bowling, sheriff, and the Badger Lumber Company, to perpetually enjoin the defendants from selling certain real estate upon execution. The defendants demurred to the plaintiffs’ petition, upon the ground that it did not state facts sufficient to constitute a cause of action, which demurrer was overruled, and the defendants electing to stand upon their demurrer, judgment was rendered in favor of the plaintiffs and against the defendants, in.accordance with the prayer of the plaintiffs’ petition; and the defendants, as plaintiffs in error, bring the .case to this court for review.
It appears that on June 5, 1888, the June term of the district court of Wyandotte county commenced. On that day, and prior thereto, Ered. M. Cox was the owner of the real estate now in controversy, which real estate was, however, subject to a mechanic’s lien held by the plaintiffs amounting to $2,380, and subject to three mortgage liens aggregating $4,346.52. At that time, and prior thereto, the plaintiffs were partners, doing business under the firm-name of the Wyandotte Lumber Company; and the defendant, the Badger’ Lumber Company, was and is a Missouri corporation. On that day, and prior thereto, the plaintiffs had an action pending in the district court of Wyandotte county against Cox to foreclose the aforesaid mechanic’s lien; and the Badger Lumber Company also had an action pending in said court against Cox for about $2,344. But there is no pretense that the Badger Lumber Company had any lien upon the property at that time. On June 7, 1888, the plaintiffs and Cox settled their affairs, and as a result of such settlement Cox, in consideration of the aforesaid mechanic’s lien and of the aforesaid mortgages which the plaintiffs agreed to pay, conveyed *516to them the property in controversy, which, as before stated, was subject to said mechanic’s lien and to the aforesaid mortgages. The deed of conveyance from Cox to the plaintiffs was recorded on the same day, and on the same day the plaintiffs dismissed their action against Cox to foreclose their mechanic’s lien and discharged the lien. Immediately afterward the plaintiffs took the possession of the property, and have had the possession ever since. Afterward the plaintiffs paid on said mortgages the amount of $2,127.50. Afterward, and on September 8, 1888, the defendant the Badger Lumber Company obtained a judgment in the district court in its aforesaid action against Cox for the sum of :$2,344; and this judgment, under the provisions of §419 of the civil code, would relate back to June 5, 1888, when that term of the court commenced, and be a lien upon all the real estate owned by Cox at that time and in the meantime aud subject to execution. On April 5, 1889, an execution was 'issued upon the judgment in favor of the Badger Lumber •Company and against Cox, and was placed in the hands of the defendant Thomas B. Bowling, who was then the sheriff of Wyandotte county; and afterward, under the authority of such execution, he levied upon the property now in controversy, and advertised the same to be sold on May 20, 1889; but prior to May 20, 1889, and on May 11, 1889, the plaintiffs, Garrett and Griest, commenced this present action against Bowling and the Badger Lumber Company to perpetually •enjoin and restrain them from making such sale; and the only question now to be determined is, whether such an action can be maintained or not.
Before proceeding further, we might state that the plaintiffs’ petition does not state that the action of the Badger Lumber Company against Cox was pending in the district court of Wyandotte county on June 5,1888, nor does it state that the June term of such court continued until September 8, 1888, when the Badger Lumber Company’s judgment against Cox was rendered; and if such action was not pending on June 5, 1888, or if the said judgment was not rendered at the June term of *517said court, then the Badger Lumber Company’s judgment could not be a lien upon any of Cox’s real estate which he conveyed on June 7,1888. (Civil Code, §419.) The district court may have been holding a special term and not the June term of said court on September 8, 1888; but as the parties seem by their briefs to agree that the Badger Lumber Company’s action against Cox was pending on June 5, 1888, and that its judgment was rendered at the June term of such court, on September 8, 1888, we have stated these matters as facts. Neither does the plaintiffs’ petition state in express terms that the Badger Lumber Company’s execution was levied upon the property in controversy, or that the same was appraised and advertised for sale without reference to the mechanic’s lien and the mortgage liens; but we think it does so state by fair implication and inference, and in all probability such were the facts, and the petition was evidently so construed by the court below and the parties, and we shall so construe it. If the land had been levied upon and then appraised and advertised for sale subject to the aforesaid mechanic’s lien and mortgage liens, the plaintiffs we think would not have had or now have any cause of action. (Civil Code, §448, as amended in 1887.) Eor, under the facts of the case and the aforesaid statutes, the Badger Lumber Company’s judgment was a lien upon the entire property, subject, however, to the aforesaid mechanic’s lien and mortgage liens.
We would also state, before proceeding further, that the plaintiffs’ mechanic’s-lien statement was filed on December 29, 1887, and if the lien had not been discharged except by lapse of time, it would have continued to be a valid and subsisting lien for at least one year after the statement was filed, and might have continued to be a valid and subsisting lien for any greater period of time, providing a promissory note, not to become due for such greater period of time, had been given for the amount. (Mechanic’s Lien Law of 1872, § 4; Mechanic’s Lien Law of 1889, § 5.) The Badger Lumber Company’s judgment was rendered before the expiration of the year, and the June term of the district court in 1888 must also have *518expired before the expiration of the year; for the September term of such court must necessarily have commenced, under the law, on the third Monday in September of that year. (Laws of 1887, ch. 147, § 12.)
Also, before proceeding further, we would state “ that the judgment lien cannot attach to a mere naked legal estate, when the entire equitable estate is vested in some third person. And in no case will the judgment lien attach to any interest greater than the judgment debtor himself possesses in the land.” (Harrison v. Andrews, 18 Kas. 535, 541, 542, and cases there cited. “The judgment lien attaches merely to the interest of the judgment debtor in the land, and to nothing more. (Civil Code, §419.) Every equity belonging to other persons will be protected by the courts. A judgment creditor is never considered as a bona fide purchaser, or even a purchaser at all.” (Harrison v. Andrews, supra. See, also, Holden v. Garrett, 23 Kas. 98.)
We would also state that the Badger Lumber Company was not a party to the action brought by the plaintiffs against Cox to foreclose their mechanic’s lien, and it had no right to be a party to such action; for it did not have, nor even claim to have, any lien upon the property in controversy until more than three months had elapsed after the plaintiff’s action had been dismissed, and until September 8, 1888. At the time when the plaintiffs’ foreclosure action was dismissed, they could not have foreclosed their mechanic’s lien as against the Badger Lumber Company, nor even have made such company a party to the foreclosure action. Hence, if the plaintiffs’ foreclosure action had been prosecuted to final judgment, and the judgment obtained before September 8, 1888, and the property sold thereunder to satisfy the mechanic’s lien, the purchaser would undoubtedly have obtained a good and valid title, free and clear from all claim of the Badger Lumber Company. Then why might not the plaintiffs, instead of prosecuting their action to final judgment at great cost and expense, settle their affairs with the defendant Cox, and take the property in payment of their mechanic’s lien, free and *519clear frbm the claim of the Badger Lumber Company? Such would seem to be equity. Or does the law favor litigation? Would the law be so inequitable as to require the holder of a lien of any kind upon real estate to prosecute his claim in the courts to final judgment at great inconvenience and cost, when he could compromise and settle his claim with his debtor to the satisfaction of both parties, and without inconvenience or costs? And would the law require this or require him to lose everything?
The only distinction between the two cases is this: If the plaintiffs’ action had been prosecuted to final judgment, only so much of the property would have been sold as would satisfy the liens upon it, and any surplus arising from the sale after satisfying the liens would have gone to Cox or to any of his creditors who might be entitled to it, while the compromise and settlement between the plaintiffs and Cox, and the conveyance by Cox to the plaintiffs, left the property subject to any judgment lien which might be procured against it at a term of the court then being held, and in an action pending at the commencement of the term. But the Badger Lumber Company’s judgment lien attached only to the rights and interests of Cox in and to the property, and to nothing more. It lefc the property subject to all the prior liens, the mechanic’s lien and the mortgage liens, and they have certainly not been extinguished for the benefit of the Badger Lumber Company. Certainly, by their extinguishment, so far as they have been extinguished, neither Cox nor the Badger Lumber Company has procured any enlargement of his or its rights or interests in or to the property in controversy. But these liens have not been extinguished so far as the rights of the plaiutiffs are concerned. Cox parted with all his rights and interests in and to the property before they were extinguished, and the Badger Lumber Company’s lien is upon no greater interest than Cox possessed. The Badger Lumber Company, however, makes a claim upon the following statement, found in the plaintiffs’ petition, to wit: “All of the real estate in said lien described, including that conveyed to plaintiffs, was *520released and discharged from the operation thereof.” This, of course, did not mean that the lien was discharged as to any one except as between the plaintiffs and Cox. Certainly, the plaintiffs did not intend to release the lien for the benefit of the Badger Lumber Company, but only for the benefit of Cox, and they procured a conveyance of the land from Cox to themselves in return. Their agreement to release the lien, amounting to $2,380, and their agreement to pay the mortgage debts, amounting to $4,346.52, and their actual payment of $2,127.50 thereof, were not intended for the benefit of, or as gifts to, the Badger Lumber Company, but were intended only for the benefit of Cox; and when they accepted the conveyance from Cox, which was a general warrantyjdeed for the real estate in controversy, they did not intend that this conveyance should inure to the benefit of the Badger Lumber Company, so that such company might obtain a judgment lien upon all the property conveyed, free and clear from the prior incumbrances of the mechanic’s lien and the mortgage liens, but they evidently intended only to protect and preserve their own interests. The whole tenor and effect of the petition shows that the plaintiffs did not intend to allege that their mechanic’s lien was released and discharged as between themselves and the Badger Lumber Company, but only as between themselves and Cox; and that they intended that all their rights and interests under the mechanic’s lien, and their settlement and compromise with Cox, their agreement to pay the mortgage debts, and the conveyance by Cox of the real estate in controversy to themselves, should preserve to them and to Cox all the rights and interests which such mechanic’s lien, settlement, compromise, agreement to pay the mortgage debts and conveyance would give or preserve to them. When t hey agreed to pay the mortgage debts, they became, according to all the authorities, as between themselves and.Cox, the principal d ebtors as to such mortgage debt, and Cox, who up to that time was the principal debtor, then became only a surety. (Stove Works v. Caswell, 48 Kas. 689; same case, 29 Pac. Rep. 1072.)
*521The Badger Lumber Company’s judgment was not rendered against Cox until more than three months after Cox had conveyed by a general warranty deed to the plaintiffs all his possible interests in the property in controversy; yet, under the statutes, (Civil Code, §419,) and by relation, the company by such judgment obtained a lien upon and a right to have sold upon execution whatever interest Cox may have had in such real estate at the time when he conveyed the same to the plaintiffs, but the company did not obtain a right to have any greater interest levied upon or appraised or advertised for sale or sold. The statute upon this subject reads as follows:
“If any of the lands and tenements of the debtor which may be liable shall be encumbered by mortgage or any other lien or liens, such lands and tenements may be levied upon and appraised and sold subject to such lien or liens, which shall be stated in the appraisement.” (Civil Code, §448, as amended in 1887.)
The sheriff, however, in this present case, at the instance of the Badger Lumber Company, has levied upon, has had appraised, has advertised for sale, and will sell if not prevented, a greater interest in the property than Cox had when he conveyed the property to the plaintiffs. Have the plaintiffs no remedy, or will injunction lie? As to subrogation, see the cases of Crippen v. Chappel, 35 Kas. 495, 499; Yaple v. Stephens, 36 id. 680. In the first of the above cases it is said:
“ Generally where it is equitable that a person furnishing money to pay a debt should be substituted for the creditor or in place of the creditor, such person will be so substituted.”
See, also, with regard to mechanics’ liens and preventing a merger, the case of Construction Co. v. D. & St. P. Rld. Co., 46 Iowa, 406. In that case it is decided as follows:
“ When the holder of a lien acquires the legal title to the property upon which it rests with the intention that the lien should not be merged therein, the intention of the lien holder will prevail, as against junior incumbrancers.” (Syllabus.)
*522In the case of Richardson v. Hockenhull, 85 Ill. 124, it is decided as follows:
“A court of equity will keep an incumbrance alive or consider it extinguished, as will best serve the purposes of justice and the actual and just intention of the parties. The intention is the controlling consideration, and to arrive at this the court will look into all the circumstances of the case.
“If a mortgage is the eldest lien, and is for an amount equal to or exceeding the value of the mortgaged premises, aud the mortgagee, to avoid the expense of foreclosure, takes a conveyance from the mortgagor, a court of equity will not permit the mortgaged premises to be swept away from him by a junior judgment creditor, without payment of the mortgage, under the pretense that its lien has been lost by merger, but will enjoin the sale at law, or restrict the judgment creditor’s lien to the equity of redemption.” (Syllabus.)
In the case of Brooks v. Rice, 56 Cal. 428, it is decided as follows:
“A conveyance of mortgaged premises by a mortgagor to a mortgagee, made in satisfaction of the mortgage, and for the purpose of avoiding the expense of a foreclosure, held, where there was an intervening mortgage, not to operate a merger.” ( Syllabus.)
In the case of Hanlon v. Doherty, 109 Ind. 37, it is decided as follows:
“Even when the fee in the mortgaged property has been vested in the mortgagee by a conveyance from the mortgagor, and the mortgage has been released, it will still be upheld, whenever it is for the interest of the mortgagee, by reason of some intervening title or other cause, that it should not be regarded as merged.” (Syllabus.)
*5231. Mechanic’s ance~"o0f°prop-' erty to lienor -merger. „ ,. 2. Execution— from Mortgage lien-T , „ eoutio°ns¡ie-" judgment. *522See, also, the following cases: Bruse v. Nelson, 35 Iowa, 157; Lowman v. Lowman, 118 Ill. 582; Watson v. Gardner, 119 id. 312; Rumpp v. Gerkens, 59 Cal. 496; Besser v. Hawthorne, 3 Ore. 130; Young v. Hill, 31 N. J. Eq. 429; Van Duyne v. Shann, 41 id. 311; Stantons v. Thompson, 49 N. H. 272.) It is our opinion that whenever the holder of a mechanic’s lien acquires the title to the property upon which the *523mechanic’s lien exists by a conveyance thereof from the owner, and not by a foreclosure in the _ _ . . courts, though that would be equally good, the mechanic’s lien will not be so merged in the legal title or be so extinguished or destroyed that a judgment subsequently rendered in favor of a third person against such owner, but rendered at a term of the court commenced before the conveyance was made, and in an action pending at the beginning of the term, would create a judgment lien prior or superior to the mechanic’s lien, or would authorize the property to be sold on an execution issued on such judgment, free and clear from such mechanic’s lien; and we would also think that, in such a case, where a part of the consideration for the conveyance by the owner to the holder of the mechanic’s lien was that the holder of the mechanic’s lien should pay r J and satisfy certain mortgages then existing upon the real estate, a portion of the amount of which mortgages he did pay, the property could not properly be sold on such execution free and clear from such mortgages. And we would also think that injunction would be the proper remedy by the holder of the mechanic’s lien against the judgment creditor to protect his interests as against such sale, and this upon the authority of the case of Plumb v. Bay, 18 Kas. 415. (See, also, Richardson v. Hockenhull, 85 Ill. 124; Young v. Hill, 31 N. J. Eq. 429.) And we also think that injunction is the proper remedy in the present case. For instance, if the plaintiffs had not commenced any action, but had permitted the property to be sold on the execution to an innocent purchaser, such innocent purchaser would undoubtedly have obtained the title to the entire property, freed from the mechanic’s lien and from all that the plaintiffs had paid on the mortgages; for no record could at that time have been found showing conclusively that the mechanic’s lien had any legal or valid existence for any amount, and no record could then have been found showing the amount paid on the mortgages by the plaintiffs. All these matters rested in evidence out*524side of records, and when the plaintiffs alleged them in their petition, the defendants could have controverted them by answer, if they had so chosen. If the defendants had desired to contest the validity or the amount of the mechanic’s lien, or of the mortgage liens, or any part thereof, or any supposed rights of the plaintiffs founded thereon, they could have done so and perhaps can still do so in this present action, by filing a proper answer and going to trial upon the merits of the action. As before stated, the Badger Lumber Company had the right, and still has the right, to have the property in controversy sold upon execution to satisfy its judgment, provided, however, that it is sold subject to all the rights of the plaintiffs founded upon their mechanic’s lien and the mortgage liens.
It follows from the foregoing views, that the decision of the court below in overruling the defendants’ demurrer to the plaintiffs’ petition was and is correct,and it will be affirmed; but we would think that the final judgment of the court below, after overruling the demurrer, was broader than it should have been, and it will be modified in accordance with the views herein expressed.
All the Justices concurring.