Herbert J. Treeby and wife gave a mortgage to Union Central Life Insurance Company on real estate in Brown county. In an action to foreclose the mortgage, Co-operative Lumber Company, the plaintiff in this action, was made a defendant, and in its answer claimed to have a mechanic’s lien which was superior to the mortgage. In the foreclosure action it was adjudged that the mortgage was the superior lien. On appeal this court reversed the judgment in that respect, and held that the mechanic’s lien was superior to the mortgage (Union Central Life Ins. Co. v. Co-op. Lumber Co., 51 S. D. 197, 212 N. W. 876), and, upon remand to the trial court judgment was entered pursuant to the mandate of this court, modifying the decree of foreclosure and adjudging that the mechanic’s lien was superior to the mortgage, and that all persons claiming through the insurance company, under and by virtue of the mortgage, “be barred, enjoined and restrained from claiming or asserting any right, title or interest in and to said real property, superior to the rights of plaintiff under said mechanic’s lien.” The lumber company on its appeal from the foreclosure decree gave no stay bond, and before the reversal of that decree the mortgagee had sold the mortgaged premises and had bid them in at the foreclosure sale and received a sheriff’s certificate of sale therefor, and had procured an order of confirmation of the sale;
After entry of the modifying judgment in the foreclosure action, the present action was commenced by the lumber company to foreclose its mechanic’s lien, and some months later, the period for redemption from the foreclosure sale having expired and no redemption having 'been made, the mortgagee took a sheriff’s deed to the premises, and by supplemental answer in the present action it set up as a defense and counterclaim the sale, its confirmation, and the acquisition of the sheriff’s deed thereunder, claiming *316title under the sheriff’s deed, “free and clear of plaintiff’s claim.” To the supplemental answer and counterclaim plaintiff replied, setting forth the reversal and modification by this court of the judgment in the foreclosure action, the modifying judgment of the trial court entered pursuant to the mandate of this court, the commencement of the present action, and the filing of a lis pendens therein before respondent took its sheriff’s deed, and that respondent has and retains all the proceeds of the foreclosure sale. To this reply the insurance company demurred on the ground that the reply did not state facts sufficient to constitute a defense to the counterclaim, and, from an order sustaining the demurrer, plaintiff appeals.
Rev. Code 1919, § 2648, provides, “if any judgment, in satisfaction of which any real property be sold, shall at any time thereafter be reversed, such reversal shall not defeat or affect the title of the purchaser; but in such case restitution must be made by the judgment creditor of the money for which such real property was sold, with lawful interest thereon from the day of sale.”
Respondents say that, since this section makes no exception of the case where a judgment creditor is the purchaser, no' exception can be implied, and, no appeal from that order of confirmation in the foreclosure action having been taken, the order cannot be assailed collaterally; therefore the sheriff’s deed gives respondent a title which cannot be defeated or affected :by the reversal of the judgment in that action.
The order of confirmation determines nothing' as to the validity of the title, but only determines that the proceedings relative to the sale are regular. Crouch v. Dakota, W. & M. R. Co., 18 S. D. 540, 101 N. W. 722; St. Paul Trust & Savings Bank v. Olson, 52 N. D. 315, 202 N. W. 472.
We think the mischief sought to be remedied by section 2648 necessarily implies that the word “purchaser,” as used therein, means a purchaser who is not a party to the erroneous judgment nor responsible therefor. It is so held in Coon v. O’Brien, 107 Neb. 427, 186 N. W. 340, citing Hubbard v. Ogden, 22 Kan. 671. The Nebraska statute is substantially similar to section 2648 of our Code, and we agree with the construction placed upon the word “purchaser” in the case of Coon v.- O’Brien.
*317Respondent’s certificate of sale was only a lien on the premises (Farr v. Semmler, 24 S. D. 290, 123 N. W. 835), and, before respondent took any deed, that lien was expressly adjudged to be inferior to plaintiff’s lien, and therefore, when the sheriff’s deed was taken by respondent, it was a deed subject to the mechanic’s lien.
Furthermore, the provisions of section 2648, relating to restitution, are not applicable, to the situation in this case in any event. The reversal of the .judgment in the foreclosure action did not defeat or affect the title of the purchaser. The purchaser at a foreclosure sale takes the property subject to prior liens and incumbrances. 42 C. J. 256. “The price bid was fo-r the equity of redemption, not for the tract free of incumbrances.” Boyce v. Hawn, 52 S. D. 53, 216 N. W. 589. When the judgment in the foreclosure action was reversed, the purchaser at the foreclosure sale still had all of the title that it acquired at the sale. Its title was not affected by the reversal. When it purchased, it was bound to know that, until the time for appeal passed, the question of priority of the mortgage over the mechanic’s lien was not finally adjudicated, and it took the risk of a reversal of the judgment on the question of priority when it made its bid.
The sheriff’s deed vested in the purchaser only the same estate that was vested in the mortgagor at the time of the execution and delivery of the mortgage or at any time thereafter. Rev. Code 1919., § 2904. The reversal does not deprive the purchaser of that title nor affect the title.
Respondent contends that, as against the Treebys, the former owners of the land, it has not yet been determined that plaintiff has a valid mechanic’s lien, and that therefore it cannot be held that respondent’s deed is subject to such lien. But, by demurring to the reply, respondent has conceded, for the purpose of this appeal that plaintiff has a valid mechanic’s lien, and, as against respondent, at any rate, the decision of this court in Union C. L. Ins. Co. v. Co-op. Lumber Co., supra, is res judicata on that question.
The order appealed from is reversed.
SHERWOOD, P. J„ and FOLLEY, CAMPBELL, and BURCH, JJ., concur.