70-24-421. Action for nonpayment of rent -- tenant's counterclaim. (1) In an action for possession based upon nonpayment of the rent or in an action for rent when the tenant is in possession, the tenant may counterclaim for any amount the tenant may recover under the rental agreement or this chapter. The court from time to time may order the tenant to pay into court all or part of the rent accrued and thereafter accruing and shall determine the amount due to each party. The party to whom a net amount is owed must be paid first from the money paid into court and the balance by the other party. The court may at any time release money paid into the court to either party if the parties so agree or if the court finds a party entitled to the sums released. If no rent remains due after application of this section, judgment must be entered for the tenant in the action for possession.
(2) In an action for rent when the tenant is not in possession, the tenant may counterclaim as provided in subsection (1) but is not required to pay any rent into court.