
465 S.E.2d 774 (1995)
CEDAR CREEK PROPERTIES, Appellant,
v.
CANTELOU ASSOCIATES, INC., Respondent.
No. 2430.
Court of Appeals of South Carolina.
Submitted September 12, 1995.
Decided December 19, 1995.
Henry W. Brown and Wm. Leighton Lord, III, both of Nexsen, Pruet, Jacobs & Pollard, of Columbia, for appellant.
*775 Frederick A. Gertz, of Gertz & Moore, of Columbia, for respondent.
CONNOR, Judge:
In this action to dissolve a mechanic's lien, Cedar Creek Properties appeals the trial court's dismissal of its complaint seeking attorney fees. We reverse and remand.
In October 1989, Cedar Creek contracted with Cantelou to plan and complete certain improvements to a residential community. On January 5, 1994, Cantelou filed and served Cedar Creek with notice of a $900,100 mechanic's lien on the improvements. Cedar Creek filed a summons and complaint as well as a motion for an expedited hearing to determine the validity of the lien on January 26. It also sought attorney fees. Although a hearing was scheduled, Cantelou agreed to cancel the lien prior to hearing. It filed a cancellation of the lien on February 7, 1994.
Thereafter Cantelou moved, pursuant to Rule 12(b)(6), SCRCP, to dismiss Cedar Creek's complaint for failure to state a cause upon which relief could be granted on the grounds all issues had been rendered moot by the cancellation of the lien. It also alleged Cedar Creek's complaint failed to present an actionable claim for attorney fees. The trial court granted Cantelou's motion to dismiss the complaint. Cedar Creek then moved for reconsideration of the order dismissing its claim for attorney fees. The trial court struck its previous order and substituted an order which again dismissed Cedar Creek's complaint. In this order, the trial judge specifically found the causes of action set forth in Cedar Creek's complaint did not fall under the provisions of S.C.Code Ann. §§ 29-5-10 through 29-5-430 (1991 & Supp. 1994), the mechanic's lien statute. This appeal followed.
On appeal, Cedar Creek argues the trial court erred in refusing to consider its claim for attorney fees under the mechanic's lien statute.
It is well settled attorney fees are not recoverable unless authorized by contract or statute. Baron Data Systems, Inc. v. Loter, 297 S.C. 382, 377 S.E.2d 296 (1989). Because it is uncontested Cedar Creek's contract with Cantelou did not address the issue of attorney fees, the resolution of the fee issue in this case necessarily involves statutory interpretation. In interpreting a statute, the primary rule of construction is to ascertain the intention of the legislature. First South Savings Bank, Inc. v. Gold Coast Assoc., 301 S.C. 158, 390 S.E.2d 486 (Ct.App. 1990).
South Carolina Code Ann. § 29-5-10(a) (1991), allows the filing of a mechanic's lien by persons who, by agreement or with consent of the owner, perform labor on or furnish materials and, in addition, provides:
The costs which may arise in enforcing or defending against the lien under this chapter, including a reasonable attorney's fee, may be recovered by the prevailing party.
In our view, the costs and attorney fees Cedar Creek incurred in its effort to dissolve Cantelou's lien constitute costs which arose in defending against a lien under this statute. Clearly, the intent of the legislature in allowing the prevailing party in an action brought under the mechanic's lien statute to recover attorney fees and costs stems from a desire to deter both wrongful filing of liens and unjustified refusal to pay debts subject to mechanic's liens. Here, Cantelou filed and served the lien against Cedar Creek's property in accordance with the provisions of § 29-5-10, and thereby effectuated a cloud over title to the property. Cantelou's actions restricted Cedar Creek's ability to transfer the property or to use it as collateral. Having availed itself of protections afforded under the mechanic's lien statute, Cantelou invoked the full operation of the statute, including the possibility Cedar Creek would prevail in its attempts to avoid the lien. Cedar Creek's decision to offensively seek dissolution of the lien rather than wait for Cantelou to seek foreclosure cannot be said to act as a waiver of Cedar Creek's potential right to collect attorney fees and costs under § 29-5-10(a).
*776 Moreover, Cedar Creek is the "prevailing party" in this action. Although Cantelou voluntarily cancelled the lien, it did so only after Cedar Creek instituted an action to have the lien dissolved. Thus, although Cedar Creek essentially got the relief it sought, that is, avoidance of the lien, it still had to defend against the lien until the issue was resolved, and it incurred attorney fees and costs during that time.[1]
Because we have held Cedar Creek is the "prevailing party" in this action under the mechanic's lien statute, the trial court must, on remand, award attorney fees to Cedar Creek. T.W. Morton Builders, Inc. v. von Buedingen, ___ S.C. ___, 450 S.E.2d 87 (Ct.App.1994) (holding the provision in § 29-5-10 which states the prevailing party in a mechanic's lien action "may" recover attorney fees is to be interpreted as mandatory). However, the amount should be limited to those actions specifically involving the lien.
REVERSED AND REMANDED.
HOWELL, C.J., and SHAW, J., concur.
NOTES
[1]  A contrary interpretation of § 29-5-10(a) would allow a party to file a mechanic's lien, encumbering the defendant's title to the property, yet never face the possibility of having to pay attorney fees so long as the lien was cancelled prior to trial. This result cannot have been the legislature's intent.
