
906 So.2d 1194 (2005)
William SWAFFORD and Sandy Swafford, Husband and Wife, Appellants,
v.
Harold SCHWEITZER, an individual, Appellee.
No. 4D04-2496.
District Court of Appeal of Florida, Fourth District.
July 20, 2005.
*1195 Edward T. Dinna of the Law Office of Edward T. Dinna, Fort Lauderdale, for appellants.
Joseph B. Heimovics of Graner Root & Heimovics, P.A., Boca Raton, for appellee.
PER CURIAM.
Upon Harold Schweitzer's Motion to Dismiss Third Amended Counterclaim, the trial court dismissed with prejudice William and Sandy Swafford's claim for unjust enrichment. Schweitzer argued that the claim failed to state a cause of action and was barred by the statute of limitations. The trial court did not state its grounds for dismissal. We reverse.
To state a cause of action for unjust enrichment, the complaint must allege:
(1) plaintiff has conferred a benefit on the defendant, who has knowledge thereof; (2) defendant voluntarily accepts and retains the benefit conferred; and (3) the circumstances are such that it would be inequitable for the defendant to retain the benefit without paying the value thereof to the plaintiff.
Hillman Constr. Corp. v. Wainer, 636 So.2d 576, 577 (Fla. 4th DCA 1994). The Swaffords allege in their claim for unjust enrichment that they made valuable improvements to Schweitzer's property that Schweitzer accepted and has retained. The Swaffords made the improvements in contemplation of purchasing the property and since that transaction will not take place, it would be inequitable for Schweitzer to retain the benefits conferred without paying for them.
We find that the Swaffords' counterclaim for unjust enrichment states a claim for unjust enrichment and the trial court erred in dismissing it.
The statute of limitations on a claim for unjust enrichment is four years. § 95.11(3)(k), Fla. Stat. (1999). Generally, the statute of limitations is an affirmative defense. Fla.R.Civ.P. 1.110(d). However, "the rule also provides that if an affirmative defense appears on the face of the complaint, the complaint may be challenged by a motion to dismiss." Erwine v. Gamble, Pownal & Gilroy, Architects and Engineers, 343 So.2d 859, 861 (Fla. 2d DCA 1976).
The counterclaim in this case was filed in February 2003 and the Swaffords allege that they made improvements to the property until their dispute with Schweitzer began in November 2001. Therefore, *1196 any improvements made after February 1999 would not be barred by the statute of limitations.
We, therefore, reverse and remand for further proceedings.
Reversed and Remanded.
STEVENSON, C.J., TAYLOR and HAZOURI, JJ., concur.
