
538 A.2d 265 (1988)
Patricia CUNNINGHAM, et al.
v.
Vauna HAZA.
Supreme Judicial Court of Maine.
Argued January 20, 1988.
Decided February 29, 1988.
Sandra H. Collier (orally), Silsby & Silsby, Ellsworth, for plaintiffs.
Christopher C. Leighton (orally), Asst. Atty. Gen., Dept. of Human Services, Augusta, for defendant.
Before NICHOLS, ROBERTS, WATHEN, GLASSMAN, SCOLNIK and CLIFFORD, JJ.
WATHEN, Justice.
The plaintiffs, Scott and Patricia Cunningham, husband and wife, and James McCoy, minor son of Patricia, appeal from an order of the Superior Court (Hancock County) granting judgment on the pleadings in favor of defendant Vauna Haza.[1] On appeal, plaintiffs contend that the Superior Court erroneously determined that defendant's immunity from suit was affirmatively established as a matter of law by the *266 allegations in their complaint. We find that the Superior Court erred and we vacate the judgment.

I.
The factual allegations in plaintiffs' complaint may be summarized as follows: In November 1985, the Department of Human Services received a referral which alleged that a certain group of young children were involved in inappropriate sexual activity. Defendant, a child protective caseworker for the Department, was assigned to investigate the referral. On November 7, defendant went to the Bay School in Blue Hill as part of her investigation. While there, she interviewed plaintiffs' minor son, James McCoy, despite his not having been named in the initial referral. Moreover, the interview was conducted without any notice to his mother and step-father and without reasonable grounds to believe that prior notice would increase the threat of serious harm to the child. During the interview, defendant, concluding that some sort of child abuse had occurred in the Cunningham's home, pulled down James's pants and examined him. Later that same day, defendant went to plaintiffs' residence in order to question them concerning the possibility that James had been sexually abused by his stepfather. She was accompanied by two Maine State Troopers who also interviewed plaintiffs. Despite plaintiffs' denial that James had ever been abused, defendant stated that she would seek a preliminary protection order unless Mr. Cunningham left the home and agreed to have no contact with James. Under the threat of defendant's seeking such an order, Mr. Cunningham agreed to leave the home and to abide by the Department's demands.
Two weeks later, defendant was contacted by a physician and a psychologist hired by plaintiffs. Both doctors informed defendant that their examination of James did not produce any evidence of his having been sexually abused by Mr. Cunningham. Plaintiffs' attempts to change the Department's position based on these findings, however, were unsuccessful. Consequently, on November 22, Mr. Cunningham returned home without informing the Department that he had done so. Defendant interviewed James a second time on November 25. During this discussion, James denied that he had been sexually abused by Mr. Cunningham. Defendant did learn, however, that Mr. Cunningham had returned to the Cunningham residence. Defendant then requested and received a preliminary child protection order on November 27, 1985. Pursuant to that order, James was removed from plaintiffs' home and placed in the temporary custody of a foster home that night. At the December 5 hearing on the Preliminary Child Protection Order, however, the Department voluntarily dismissed the petition for "insufficient evidence", and James was returned to his parents.
Plaintiffs also allege that, during the investigation of this matter, defendant made improper statements to neighbors, to the Maine Department of Education, to James's natural father and, on information and belief, to others unknown to plaintiffs. Plaintiffs allege that defendant indicated to these people that Mr. Cunningham had been charged criminally with sexual abuse of James, that the Department had "verified" that Mr. Cunningham had sexually abused James, that the Department "had a great case against Scott" for sexual abuse, and that defendant had made other statements of a similar nature.
In separate counts of their complaint, plaintiffs claim that defendant's conduct constituted an assault, invasion of privacy, intentional infliction of emotional distress, negligence, defamation of character, and a deprivation of civil rights under 42 U.S.C. § 1983. In each count, with the exception of the count for negligence, plaintiffs alleged that defendant acted with malice and sought punitive as well as compensatory damages. Defendant filed an answer and asserted inter alia the affirmative defense of immunity conferred by the Maine Tort Claims Act. On the basis of that same affirmative defense, defendant moved for judgment on the pleadings. The Superior Court granted judgment on the pleadings *267 on all counts and it is from this order that plaintiffs appeal.

II.
Initially, it is important to note the procedural posture in which this case is presented. When, as in this case, a motion under M.R.Civ.P. 12(c) for judgment on the pleadings is filed by a defendant, only the legal sufficiency of the complaint is tested.[2] Defendant's motion for judgment on the pleadings is nothing more than a motion under M.R.Civ.P. 12(b)(6) to dismiss the complaint for failure to state a claim upon which relief can be granted. Burke v. Hamilton Beach Division, 424 A.2d 145, 148 (Me.1981); see 1 Field, McKusick & Wroth, Maine Civil Practice § 12.14 (2d ed. 1970). Ordinarily, a defendant is not entitled to take advantage of an affirmative defense in presenting such a motion, because matters set forth in his answer are taken as denied or avoided. M.R.Civ.P. 8(d). Conflict between pleadings can be reached only by motion for summary judgment or trial. Thus, in the usual case, the court resolves a defense motion for judgment on the pleadings by assuming that the factual allegations are true, examining the complaint in the light most favorable to plaintiff, and ascertaining "whether the complaint alleges the elements of a cause of action or facts entitling the plaintiff to relief on some legal theory." Robinson v. Washington County, 529 A.2d 1357, 1359 (Me.1987).
We have previously noted one narrow exception to the rule that an affirmative defense cannot be invoked as a ground for dismissal. If the complaint itself affirmatively demonstrates the existence and the applicability of the affirmative defense, then the defense may serve as the basis for dismissal. Robinson v. Washington County, 529 A.2d at 1361; McKerron v. Madura, 445 A.2d 680, 682 (Me.1982). Under any circumstances, however, "a complaint should not be dismissed for insufficiency unless it appears to a certainty that plaintiff is entitled to no relief under any state of facts which could be proved in support of the claim." Richards v. Ellis, 233 A.2d 37, 38 (Me.1967) (quoting 2A Moore's Federal Practice ¶ 12.08) (2d ed.).
In the present case, the Superior Court determined that plaintiffs' complaint demonstrated affirmatively that defendant was personally immune from liability on all counts. The court erred. Many of the factual allegations in plaintiffs' complaint could fall within the personal immunity granted to state employees for the performance of discretionary acts.[3] At a minimum, however, plaintiffs' complaint alleges that defendant acted beyond the bounds of any statutory authority she might have, and that she acted with malice. Accepting those allegations as true, as we must, we cannot say with certainty that defendant is immune from liability as a matter of law under any set of facts which could be proven in support of plaintiffs' claim. Plaintiffs' complaint is legally sufficient and defendant's affirmative defense must await further factual development.
The entry is:
Judgment in favor of defendant Vauna Haza vacated.
All concurring.
NOTES
[1]  The Superior Court also granted judgment in favor of the State of Maine and the commissioner of the Department of Human Services. Plaintiffs do not appeal from that ruling and acknowledge that these defendants are immune from suit.
[2]  A motion for judgment on the pleadings filed by the plaintiff tests the legal sufficiency of the affirmative defenses set forth in the defendant's answer. See 1 Field, McKusick & Wroth, Maine Civil Practice § 12.14 (2d ed. 1970).
[3]  14 M.R.S.A. § 8111 provides in relevant part:

1. Immunity. Employees of governmental entities shall be personally immune from civil liability for the following:
C. The performance or failure to exercise or perform a discretionary function or duty, whether or not the discretion is abused; and whether or not the statute, charter, ordinance, order, resolution, regulation or resolve under which the discretionary function or duty is performed is valid;
