If a civil action, including an action for appeal of a zoning decision, or special proceeding is dismissed or requested relief is denied and if the court determines that it was frivolous or brought for malicious purposes, the court shall order the party whose claim, cause of action, or defense was dismissed or denied to pay part or all expenses incurred by the party defending the matter, including reasonable attorneys' fees.
SDCL 15-17-51