Dickinson, J.
Two former appeals in this action are reported in 42 Minn. 427, (44 N. W. Rep. 313,) sub nom. Ness v. Wood, and 45 Minn. 424, (48 N. W. Rep. 10.) On the first appeal it was decided that the claim of the plaintiff was chargeable as a mechanic’s lien upon the interest of this appellant, Edward E. Davidson, in the land devised. On the second appeal, it appearing that the executors had then exercised the power to sell conferred upon them by the will of the testator, it was considered that by the sale and conveyance the land was transferred to the purchaser free from any such lien, for the reason that the devisees could not incumber the estate so as to obstruct or defeat the execution of the power. The effect of the two decisions was that the estate of the appellant in the land was chargeable with the mechanic’s lien, but that such estate was liable to be divested by the exercise of the power of sale conferred by the will, in which case he would become entitled under the will to the proceeds of the sale in lieu of the land itself; that his estate in the land was so divested, with the effect also to discharge the lien from the land.
After the remanding of the case to the district court, a supplemental complaint was allowed and filed, setting up the fact of the sale of the land, and that the appellant had received a portion of the proceeds of the sale, and it was prayed that the appellant be adjudged to hold such proceeds, to the extent of the plaintiff’s lien claim, in trust for its satisfaction; and after a retrial of the case, upon issues, joined, equitable relief of that nature was granted. This is an appeal from the judgment.
The power of the court to enforce payment of the plaintiff’s claim out of the proceeds of the sale of the land is denied by the appellant upon three grounds, it being contended (1) that the plaintiff’s right *477to charge the property of the appellant with a lien, being purely statutory, cannot be extended by the application of general principles of equity, so as to bind or affect other property than the land and structures which the statute declares to be subject to such liens; (2) that, even if equitable principles are applicable, this case is not within the principle invoked in support of the judgment; that the cases in which a charge or claim resting upon specific property will be, upon equitable grounds, transferred to or imposed upon other property which has been substituted for that originally charged, are confined to two classes, neither of which includes this case, viz. (a) cases of constructive trust arising from a conversion or substitution of property through some wrong or fraud, actual or constructive, and (h) eases of execution or judicial sales, or where there has been a conversion of the property under a statutory power; and (3) that the fund arising from the execution of the power of sale conferred by the testator is not chargeable with this lien, because, as is contended, under the doctrine of equitable conversion, the actual conversion of the property by the sale related back, in legal contemplation, to the time of the death of the testator, and hence the property devised should be treated as having been personal property from the time of the death of the testator, passing as such under the will, as of the time when the will became effectual, and never subject to a mechanic’s lien, which is chargeable only upon interests in real property. These propositions have been supported by able arguments, but we do not yield our assent to them.
Without reviewing the ground covered by our former decisions, the correctness of which is not questioned, we enter upon the consideration of the case with the premise that the appellant had an estate in the land devised, although it was liable to be divested by the execution of the power of sale, in which case the proceeds of the land were to go to him as a substitute for the land itself. The further premise is to be accepted that the appellant’s estate, while it existed, was actually charged with the plaintiff’s mechanic’s lien. The lien had been created under a contract which he had executed. In contemplation of law, the improvement went on, and the lien was imposed with his consent. His estate was as effectually charged as *478it would have been if he had executed a mortgage upon it to secure the debt of some other person. If such had been the case, and if -his estate had thereafter been terminated, and the mortgage lien upon •the land extinguished, by the execution of the power of sale conferred •by the will, the proceeds of the sale going to him under the will in place of the estate, it would seem that in equity the substituted proceeds should be regarded as a trust fund in place of the original security. As the mechanic’s lien is, in contemplation of law, created by his authority or consent, the case does not seem in this particular to be distinguishable in principle from that just supposed. The appellant’s classification of cases, in which equity will thus transfer a lien or charge from the specific property upon which it originally rested to that which becomes a substitute for it, recognizes that this will be done where, by a sale under legal or judicial process or in the execution of a statutory power, the lien is divested, as where land is .sold under a senior lien, and a price received in excess of what is necessary to satisfy it. The right of those having junior liens to have the surplus applied to the satisfaction of their claims is not •questioned, and is not a matter of doubt. Brown v. Crookston Agricultural Ass’n, 34 Minn. 545, (26 N. W. Rep. 907.) It would be difficult to assign any satisfactory reason for such a limitation of this equitable doctrine as would exclude this case from its operation, if equitable principles are to be recognized and applied in the enforcement of statutory mechanics’ liens. It can make no difference in principle whether the estate charged with the lien is sold under a paramount lien or under legal or judicial process, or, as in this case, •under a testamentary power paramount to the lien, and the execution of which is effectual to discharge the lien from the land, and to •convert the estate into money, for the benefit of the person whose •estate is sold.
The mechanic’s lien having attached to the real estate while it was vested in the appellant, and having been discharged only by a sale, which was, in effect, a conversion of the property thus •changed into money, — a substitution of the proceeds of the sale of the land for the land itself, — for the benefit of the person who •owned that estate, it is cpnsidered that the substituted fund in the *479hands of such person, the appellant, should be charged with the payment of the debt, for the payment of which he; in legal contemplation, had allowed his estate in the land to be charged. The power of the court to make the lien effectual, by thus treating the ¡substituted proceeds of the real property as subject to the liability which had been imposed on the property itself, has been asserted in Werth v. Werth, 2 Rawle, 151; Burt v. Kurtz, 5 Bawle, 246; Yearsley v. Flanigen, 22 Pa. St. 489; Robson & Co.’s Appeal, 62 Pa. St. 405: Wells v. Canton Co., 3 Md. 234, 242; Livingstone. Mildrum, 19 N. Y. 440; Ackerman v. Gorton, 67 N Y. 63; Gaty v. Casey, 15 Ill. 189; Eliett v. Tyler, 41 Ill. 449; and see 2 Jones, Mortg. (4th Ed.) § 1687; Phil. Mech. Liens, §§ 196-198. It is true that in some of these eases the question of the applicability of the equitable rule was not really involved in the case decided. From the fact that mechanics’ liens are authorized only by statute, it does not follow that equitable principles are inapplicable in proceedings to make the lien effectual; and this is a matter which pertains largely to the remedy for enforcing the lien and.making it effectual. The statute, so far as its provisions bear upon this subject, supports the conclusion above expressed. It is enacted that the holder of the lien may proceed to obtain judgment, and enforce the same in the same manner as in actions.for the foreclosure of mortgages upon.real estate. If the plaintiff’s lien had been created by a mortgage executed by the appellant on his estate, and this had been an action to foreclose the mortgage, we see no good reason to doubt that the court might treat the proceeds of the sale of the land, under the power conferred by the will, as a substitute for the land mortgaged, and transfer to such proceedings the liability previously resting upon the appellant’s estate in the land. If the court, in the exercise of its general equity power, would have given such relief in an action to foreclose the mortgage, the very terms of the statute justify the court in doing the same in this equitable action.
The third point of the appellant, founded on the doctrine of equitable conversion, is not tenable. The power to sell conferred by the will was, as we hold, clearly discretionary in the donees of the power, and no imperative duty was imposed on them. Hence there was *480no conversion of the real into personal property, even constructively, until the power was actually executed. The conversion should not be deemed to have been made as of the time of the death of the testator, but only as of the time when the power was exercised by a sale of the real estate. In re Ibbitson’s Estate, L. R. 7 Eq. 226; Edwards v. West, 7 Ch. Div. 858; Stoner v. Zimmerman, 21 Pa. St. 394; Keller v. Harper, 64 Md. 74, (1 Atl. Rep. 65;) Kouvalinka v. Geibel, 40 N. J. Eq. 443, 446, (3 Atl. Rep. 260;) 3 Pom. Eq. Jur. §§ 1160, 1162, 1163; 1 Wats. Comp. Eq. 111; Adams, Eq. 135. See notes to Fletcher v. Ashburner, 1 White & T. Lead. Cas. Eq. 1118. See, also, the opinion of Lord Eldon in Townley v. Bedwell, 14 Ves. 591. Before the conversion was effected, before the situation came to be such that the equitable principle that what ought to have been done will be deemed to have been done became applicable, the plaintiff’s lien upon the real estate vested in the appellant had been created. It was decided on a former appeal in this action that the power of sale enabled .the grantees of the power to sell the estate free from the lien. But the doctrine of equitable conversion, which extends no further than is necessary for the accomplishment of the ends to which it is directed, does not forbid that a court of equity should, in accordance with a recognized principle of equity, transfer the lien discharged from the real estate to the proceeds of such estate in the hands of the appellant.
Judgment affirmed.
(Opinion published 52 N. W. Rep. 46.)