When any foreclosure of land for taxes is adjudged to be void, the judgment must state the reason why it is void. In all such cases, and in cases when by the mistake or wrongful act of the county treasurer or auditor, land has been foreclosed upon which no taxes were due, and in cases when taxes have been or may be paid on lands not subject to taxation, or on lands when subsequent to payment the entry has been or may be canceled, the money so paid and all subsequent taxes, penalties, and costs which have been or which may be paid must be refunded, with interest at seven percent per annum from the date of payment to the person making such payment, the person's heirs or assigns, and the same must be refunded out of the county treasury to which such money was paid, on an order from the county auditor. A pro rata share of the money so refunded must be charged to the state and to any city, township, school district, or other taxing district which may have received any part of such void tax. Whenever any tax deed made and delivered under this title is adjudged to be void, unless the judgment declares the tax to be illegal, the tax and all subsequent taxes shall remain and be a lien upon the land, and the county auditor shall serve notice of foreclosure of tax lien on the following October first pursuant to chapter 57-28 for the full amount of taxes, penalties, and costs due thereon.
N.D.C.C. § 57-45-12