Order, *312Supreme Court, New York County (Elliott Wilk, J.), entered September 23, 1991, which, inter alia, granted the plaintiffs motion to dismiss the defendant’s counterclaim, unanimously reversed, insofar as appealed, on the law, the motion is denied and the counterclaim is reinstated, with costs.
The defendant issued a multi-peril insurance policy to the plaintiff, a cooperative corporation. After the plaintiffs tenant instituted an action against it alleging that the corporation and its board members breached agreements to permit the tenant to construct a cafe at the premises, the defendant, while disclaiming liability, undertook the defense of the action on behalf of the plaintiff and its board. A judgment was entered in favor of the tenant against the plaintiff in the amount of $1,571,385.26. After the Appellate Division and Court of Appeals affirmed the judgment (Greasy Spoon v Jefferson Towers, 150 AD2d 990, affd 75 NY2d 792), the defendant paid the tenant $1,150,000 pursuant to an undertaking it had posted to stay execution of the judgment.
The defendant thereafter instituted a declaratory judgment action against the plaintiff to determine whether the judgment in favor of the tenant was excluded from coverage under the insurance policy. The Supreme Court granted the plaintiffs motion to dismiss the complaint on the ground that the judgment in favor of the tenant was covered under the policy’s directors’ and officers’ liability endorsement and was not excluded from coverage under Exclusion M of the policy. This Court, by order entered September 3, 1992 [186 AD2d 10], modified, by holding that the Supreme Court should have declared the rights of the parties under the policy instead of dismissing the complaint.
The plaintiff thereafter commenced this action against the defendant to compel it to pay amounts, in excess of the policy limits already paid, to satisfy the tenant’s judgment and to recover punitive damages for the defendant’s purported bad faith failure to settle the tenant’s action. In its answer, the defendant asserted a counterclaim alleging that it was damaged by the plaintiffs failure to cooperate with the defendant in settlement negotiations in the tenant’s action, in violation of the insurance policy.
The Supreme Court, inter alia, granted the plaintiffs motion to dismiss the defendant’s counterclaim on the ground that res judicata barred the defendant from asserting the counterclaim in the instant action. As limited by its brief, the defendant contends that the Supreme Court erred in dismissing its counterclaim. We agree.
*313"At the core of the doctrine of res judicata is the concept that a valid final judgment bars further actions between the same parties on the same cause of action. (Matter of Reilly v Reid, 45 NY2d 24, 27.) If the same 'gravamen of * * * wrong’ is at issue, the subsequent action is barred. (Supra, at p 29.)” (Lukowsky v Shalit, 110 AD2d 563, 566.) However, a second action may not be barred even if both actions arise from an identical course of dealing, if the necessary elements of proof and evidence required to sustain recovery vary materially (supra).
By its counterclaim, the defendant seeks to recover damages allegedly sustained as a result of the plaintiffs failure to cooperate in settlement negotiations in the tenant’s action. In the declaratory judgment action, the issue determined was whether the insurance policy covered the judgment rendered in favor of the tenant or whether coverage was excluded. The issue raised in the counterclaim was neither raised nor litigated in the declaratory judgment action. Accordingly, the doctrine of res judicata does not bar the counterclaim since it presents a different "gravamen of the wrong” (Matter of Reilly v Reid, supra, at 29; Lukowsky v Shalit, supra; see also, Energycresent, Inc. v Creative Modules Enters., 183 AD2d 804, lv dismissed 80 NY2d 925).
Moreover, while res judicata prevents litigation of a matter that could have been raised and decided in a previous suit, an exception to this rule exists in declaratory judgment actions. The preclusive effect of the declaratory judgment is limited to the subject matter of the declaratory relief sought (Harborside Refrig. Servs. v Vogel, 959d 368, 372; Dale Renting Corp. v Bard, 39 Misc 2d 266, 267, affd 19 AD2d 799; Lynch v Bailey, 198 Misc 685, 687). The cooperation required under the insurance policy was not the subject of the declaratory judgment action.
Accordingly, the plaintiffs motion to dismiss the counterclaim is denied and the counterclaim is reinstated. Concur— Murphy, P. J., Rosenberger, Kupferman, Kassal and Nardelli, JJ.