For the purposes of the questions involved in this appeal, it may be said that the plaintiffs, as the receivers of the Northern Pacific Railroad Company, brought this action to cancel tax deeds upon certain lands situate in LaMoure county, in this state, which said lands formed a part of the place lands in the original grant of lands by congress to said railroad company, and which said lands the said County of LaMoure, by its proper officials, sold to the defendant, William Brett, at the tax sale in 1889, for the alleged taxes that had been assessed and levied thereon for the year 1888. Subsequently deeds were issued upon such sale to said defendant. It has been judicially determined that said lands were not subject to taxation by the county in said year. McHenry v. Alford, 168 U. S. 651, 18 Sup. Ct. 242, 42 L. Ed. 614; Wells Co. v. McHenry, 7 N. D. 246, 74 N. W. Rep. 241. This is conceded by said defendant, and the cancellation of said deeds is not now resisted. But the said defendant set forth in his answer, by way of counterclaim, that in January, 1890, he paid the taxes upon said lands that had been assessed and levied thereon for the year 1889, setting forth the amounts so paid; and he asks that judgment be rendered in his favor, and against plaintiffs, for the amounts so paid, with interest, penalties, and costs. It will thus appear that the single question presented for our determination is whether or not a party who purchases land at a tax sale for an unwarranted and void tax can pay subsequent valid taxes thereon, and recover from the owner the amount of the valid tax subsequently paid by him. The trial court held against the proposition, and defendant, Brett, appeals.
At the time of the sale in question, section 1643, Comp. Laws, was in force, which declares that, whenever an action is brought to set aside a tax deed, “the true and just amount of taxes due upon such property or by such person must be ascertained and judgment must be rendered and given therefor against the taxpayer.” It is doubtless true, as contended by counsel, that whatever rights then accrued to the purchaser by virtue of said statute, and other then-existing statutes in pari materia, assumed the form of contract rights, and could not be destroyed by susequent legislation. Roberts v. Bank, 8 N. D. 504, 79 N. W. Rep. 1049, and cases cited. Roberts 1626, Comp. Laws, contains this language: “The purchaser acquires the lien of the tax on the land and if he subsequently pay any taxes levied on the same whether levied for any year or years previous or subsequent to such sale, he shall have the same lien for them, and may add them to the amount paid by him in the purchase.” And section 1635 declares that “the owner or occupant of any land sold for taxes” may redeem the same within a specified time by paying the amount for which the sale was made, with *71certain interest thereon, and all subsequent taxes paid, with the same rate of interest thereon. To support his position that under these provisions he is entitled to judgment for the amount paid on the 1889 taxes, appellant cites the case of Merriam v. Hemple, 17 Neb. 345, 22 N. W. Rep. 775. Perhaps this case in an authority for appellant. As it is reported, we are not entirely certain. There a sale was set aside, but the purchaser was allowed to recover for subsequent taxes paid. Whether the court regarded the sale as invalid by reason of irregularities, or because the tax upon which it was based was void, we are not clear. It is certain the court did not intend to hold that a sale under a void tax could transfer or create any lien, because the court say: “The trial court found that the sale for the taxes of 1871 was a void sale. Such was, perhaps, the fact. But that fact could not destroy the lien of the purchaser for the taxes paid by him at such sale, if the taxes were valid, and the sale void on account of the irregularities of the revenue officers above the assessor.” The court immediately adds: “Neither could it destroy the lien for subsequent taxes legally levied, if the taxes for the year for which the real estate was sold were void.” Abstractly, this latter statement is strictly correct. A sale under a void tax could not affect the lien of the county under subsequent valid taxes; but we could not hold, under .our statutes, that a party having no lien whatever on the land to protect could voluntarily pay the subsequent taxes, and thereby acquire the lien of the county, and compel the property owner to accept him as tax collector. Appellant also cites Coonradt v. Myers, 31 Kan. 30, 2 Pac. Rep. 858. But the question here involved was not raised or. mentioned in that case. There the party whose tax title failed had paid subsequent taxes for eight years. The case turned on a three-years statute of limitations. The lower court only allowed a recovery for taxes paid within three years prior to the date of bringing suit. That was reversed, and some of the reasoning of the court supports appellant. The court places the recovery of subsequent taxes paid upon the same ground as recovery for improvements under the occupying claimant’s act, and says, in effect, that nothing can be recovered by way of improvements until the claimant’s title is declared defective; then the value of all improvements must be allowed. So, as to subsequent taxes paid, nothing can be recovered therefor until the title under the purchase is declared defective; then all that has been paid must be recovered. But we venture to suggest that nothing can be recovered under the occupying claimant’s act until the party brings himself within the terms of the act, and likewise nothing can be recovered by way of subsequent taxes paid until the party brings himself within the terms of the statutes authorizing such recovery. This court held in Budge v. City of Grand Forks, 1 N. D. 309, 47 N. W. Rep. 390, 10 L. R. A. 165, and Tyler v. Cass Co., 1 N. D. 369, 48 N. W. Rep. 232, that the rule of caveat emptor applied to a purchaser at a tax sale, *72in all its fullness. He takes his chances. If he be not within the law, he is bound, at his own peril, to know it. On this point, what were appellant’s rights under the statute? The case of McHenry v. Alford, supra, followed by this court in Wells Co. v. McHenry, supra, declared that these lands were exempt from taxation by the county for the year 1888. Being exempt, — the county being without power to tax them, — the pretended tax was a nullity. It constituted no lien in favor of the county. Section 1626, Comp. Laws, says the purchaser acquires the lien of the tax upon the laird. But in this case, there being no lien, none passed by the sale. This, under the rule of caveat emptor, the purchaser was bound to-know. He knew he was a stranger to the title. The section further says that, if he subsequently pay any taxes, he shall have the same lien for them. Now, it would seem to be clear and manifest intent of this language that the purchaser could pay subsequent taxes and acquire a lien only when he had acquired a lien by his prior purchase. There is nothing whatever in section 1643 that conflicts with this. That section relates to an attack upon a tax or tax sale. If the tax be upheld in part, or if the sale be defeated upon grounds that do not affect the validity of the tax, the court is required to render judgment for the true amount of tax due upon the property. Of course, that provision could have no application where the tax was void ab initio, as in this case. We think the purpose of the statutes quoted was to enable a purchaser at tax sale to protect his lien and increase his profits, and thereby present another inducement to bid at tax sales. It would, in our view, be highly unjust to permit one who has no lien — a stranger to the title — to step in and pay taxes before they became delinquent, as was done' in this case, and thereby throw upon the property owner the burden that would accrue upon a tax sale. We cannot so construe the statute. We believe the right to recover subsequent taxes paid must be based upon some lien acquired by a prior purchase, and in this holding we are supported by the following authorities: Barke v. Early, 72 Iowa, 273, 33 N. W. Rep. 677; Roberts v. Deeds, 57 Iowa, 320, 10 N. W. Rep. 740; Barber v. Evans, 27 Minn. 92, 6 N. W. Rep. 445; Broxson v. McDougal, 70 Tex. 64, 7 S. W. Rep. 591; Early v. Whittingham, 43 Iowa, 162; Croskery v. Busch (Mich.) 74 N. W. Rep 464.
These views lead to an affirmance of the decree in this case, but, before closing the opinion, it is proper to say that the writer hereof, while speaking of this same general subject, used language in Roberts v. Bank, 8 N. D. 504, 79 N. W. Rep. 1049, which is perhaps inadmissible. It was there said that since the passage of chapter 126, Laws 1897, a tax-sale purchaser, whose purchase was held invalid, must in all cases look to the county for reimbursement. It was said that the matter pertained to the remedy only, and was subject to legislative control. A further examination of the statute shows that such statement was incorrect. The statute does not *73pertain to the remedy exclusively. It in part destroys the right, as the recovery under that law, while identical with the recovery under chapter 132, Laws 1890, is more limited than the' recovery under the law as it existed prior to 1890. And, in so far as the language used gave to the law of 1897 unlimited- retrospective operation, it was unwarranted, and is here qualified. The judgment and decree of the District Court are adopted by this court, and in all things affirmed.
(81 N. W. Rep. 65.) All concur.