
403 So.2d 507 (1981)
Keith C. STEVENS, Jr. and Ruth Stevens, His Wife, Appellants,
v.
LEN-HAL REALTY, INC., a Florida Corporation, Appellee.
No. 80-1175.
District Court of Appeal of Florida, Fourth District.
August 26, 1981.
Rehearing Denied October 5, 1981.
*508 Sam Costa, Jr. of Sam Costa, Jr., P.A., Pompano Beach, for appellants.
Monroe Gelb of Gelb & Spatz, Miami, for appellee.
MOORE, Judge.
This is an appeal from a final summary judgment entered in an action to foreclose a mortgage on real estate. In entering the final summary judgment, the trial court relied upon the doctrine of res judicata. The issue before us is whether the doctrine of res judicata precludes relitigation of issues raised in affirmative defenses and a counterclaim when the same issues had been litigated in a prior proceeding. We affirm in part and reverse in part.
The appellants were the purchasers of a portion of property on which was constructed a motel. They executed a purchase money mortgage in favor of the appellee. The appellants intended to operate the motel in conjunction with a restaurant and marina which was to be constructed on the remaining portion of the real estate and which was to be operated by the appellee. In a previous suit, the appellee sought declaratory relief to determine the various rights of the parties regarding the subject property and an injunction from certain alleged wrongful activities of the appellants. The appellants counterclaimed in that suit, seeking to enjoin the appellee from certain alleged wrongful conduct. In the previous suit, the trial court entered a final judgment enjoining both parties from physically or emotionally harassing each other. No appeal was taken from that final judgment. In the mortgage foreclosure action before us, the appellants filed affirmative defenses and a counterclaim alleging the same wrongful conduct as they alleged in the prior suit.
The doctrine of res judicata applies when there exists: (1) identity in the thing sued for, (2) identity of the cause of action, (3) identity of persons and parties to the actions, and (4) identity of the quality or capacity of the person for or against whom the claim is made. If these four elements exist, the doctrine of res judicata acts to bar absolutely a subsequent suit on the same cause of action. Seaboard Coast Line Railroad v. Industrial Contracting Company, 260 So.2d 860 (Fla. 4th DCA 1972). The counterclaim in the present case asserts the same cause of action for injunctive relief as in the prior case. The four identities for res judicata are present. Therefore, the adjudication in the prior case constitutes an absolute bar to appellants' counterclaim here.
On the other hand, the prior case did not resolve the issues raised by appellants' affirmative defenses to the mortgage foreclosure. The appellants alleged that the appellee interfered with their business by harassing their customers and destroying their property so as to inhibit their ability to make the mortgage payments. Res judicata does not apply because the prior case was not a foreclosure action.
Furthermore, the doctrine of estoppel by judgment does not apply. This doctrine applies when the two causes of action are different, in which case the judgment *509 in the first suit estops the parties from litigating in the second suit issues common to both causes of action which were actually litigated in the prior action. See, Seaboard Coast Line Railroad, supra. In the present case, the issue of whether the appellee interfered with appellants' business, thereby hindering appellants' ability to make mortgage payments, was not litigated in the prior case. The trial court there merely enjoined the parties from harassing each other and did not address the question of whether the alleged acts interfered with appellants' ability to make mortgage payments. Therefore, summary judgment was improper in that material issues of fact remain to be determined regarding appellants' affirmative defenses to the mortgage foreclosure.
Accordingly, we affirm the final summary judgment against the appellants on their counterclaim and reverse the final summary judgment of foreclosure. In doing so, we do not express an opinion on the validity of the allegations as a defense to the mortgage foreclosure proceedings.
AFFIRMED IN PART and REVERSED IN PART.
DOWNEY, J., and BARKETT, ROSEMARY, Associate Judge, concur.
