
542 So.2d 441 (1989)
Debra A. EILER, Etc., Appellant,
v.
CAMP DRESSER & MCKEE, INC., Etc., et al., Appellees.
Nos. 88-1133, 88-1430.
District Court of Appeal of Florida, Fifth District.
April 27, 1989.
*442 Fred Tromberg of Tromberg, Shore, Harrison & Safer, Jacksonville, John R. Overchuck of Maher, Overchuck & Langa, Orlando, and William C. Gentry of Gentry and Phillips, P.A., Jacksonville, for appellant.
Michael M. Bell of Hannah, Marsee, Beik & Voght, P.A., Orlando, for appellee, Paul N. Howard Co.
Wallace W. Hardy, Orlando, for appellees Affholder, Inc., and Kern-Affholder, Inc.
No Appearance for appellees, Camp Dresser & McKee, Inc., Florida Power Corp., Orange County, Florida, Crane Carrier Co., or State of Fla., Dept. of Transp.
DANIEL, Judge.
This is a consolidated appeal taken by appellant-plaintiff below, Debra A. Eiler, from the orders of the trial court which dismissed with prejudice all counts of her complaint against appellees-defendants below, Paul N. Howard Company, Affholder, Incorporated and Kern-Affholder, Incorporated. We hold that the trial court erred in dismissing these portions of Eiler's complaint and, therefore, reverse.
In November of 1987, Debra Eiler, as guardian for her ex-husband Richard Eiler, instituted this action for damages by filing a complaint against several defendants including the Paul N. Howard Company, Affholder, Incorporated and Kern-Affholder, Incorporated. In her complaint Eiler averred that the defendants were liable for personal injuries sustained by her ex-husband as a result of an accident which occurred while he was at work. In response to Eiler's complaint, appellee Paul N. Howard Company filed a motion to dismiss the complaint and shortly thereafter appellees Kern-Affholder, Incorporated and Affholder, Incorporated filed a separate motion to dismiss. Appellees all claimed that the complaint should be dismissed as to them because appellees were entitled to immunity from suit pursuant to section 440.11 of the Workers' Compensation Act. Following a hearing, the trial court granted appellees' motions to dismiss.
On appeal Eiler contends that it was error for the trial court to dismiss her complaint based upon the finding that the Workers' Compensation Act provides appellees with immunity from suit, asserting that the defense of workers' compensation immunity is an affirmative defense which cannot be raised on a motion to dismiss. It is settled law that the function of a motion to dismiss a complaint is to raise a question of law as to the sufficiency of the facts alleged to state a cause of action and that a court may not properly go beyond the four corners of the complaint in testing the legal sufficiency of the allegations set forth therein. Reed v. Sampson, 349 So.2d 684 (Fla. 4th DCA 1977). It is equally well settled that the exclusivity provision set forth in section 440.11 of the Workers' Compensation Act is an affirmative defense which cannot be raised by a motion to dismiss unless the allegations of a prior pleading in the case demonstrate the existence of such a defense. Moucha v. Burger King Corporation, 450 So.2d 335 (Fla. 5th DCA 1984). See also Walker v. ITD Industries, Inc., 437 So.2d 230 (Fla. 2d DCA 1983).
Here, Eiler's complaint alleges a cause of action against appellees in negligence. The complaint does not contain any allegations concerning the Workers' Compensation Act. Thus, in granting appellees' motions *443 to dismiss, the trial court relied upon the existence of an affirmative defense which was established by facts which were outside the scope of the allegations contained in Eiler's complaint. This was error. The orders dismissing Eiler's complaint against appellees must, therefore, be reversed and this cause remanded for further proceedings consistent with this opinion.
REVERSED and REMANDED.
DAUKSCH and GOSHORN, JJ., concur.
