If, in any action brought by the purchaser, or other person claiming under the purchaser, to recover the possession of lands sold for taxes, a recovery is defeated on the ground that such sale was invalid for any reason other than that the taxes were not due, the court shall forthwith, on the motion of the plaintiff, ascertain the amount of taxes for which the lands were liable at the time of the sale and for the payment of which they were sold, with interest thereon from the date of sale, and the amount of such taxes on the lands, if any, as the plaintiff, or the person under whom he claims, has, since such sale, lawfully paid or assumed by the state after its purchase, with interest thereon from the date of such payment, the interest on both amounts to be computed at the rate of 12 percent per annum, subject to the limitations set forth in Section 40-10-122(a); and the court shall thereupon render judgment against the defendant in favor of the plaintiff for the amount ascertained and the costs of the action, which judgment shall constitute a lien on the lands sued for, and payment thereof may be enforced as in other cases.
Ala. Code § 40-10-76 (1975)