
709 So.2d 455 (1997)
Ex parte ALABAMA DEPARTMENT OF FORENSIC SCIENCES and State Medical Examiner Gregory P. Wanger.
(In re Bettie SMITH, et al. v. Gregory P. WANGER, M.D., et al.).
1961759.
Supreme Court of Alabama.
November 14, 1997.
Rehearing Denied January 16, 1998.
*456 Bill Pryor, atty. gen., and Stanley E. Graham and Alice Ann Byrne, asst. attys. gen., for petitioners.
Randolph B. Walton of Walton, Ritchie & Green, L.L.C., Mobile, for respondents.
PER CURIAM.
The defendants, the Alabama Department of Forensic Sciences ("the Department") and State Medical Examiner Dr. Gregory P. Wanger, petition for a writ of mandamus directing Judge Edward B. McDermott, of the Mobile Circuit Court, to grant their Rule 12(b)(6), Ala. R. Civ. P., motion to dismiss the complaint against them. They claim to be entitled to the dismissal, based upon the defenses of sovereign immunity and qualified immunity, relying on § 14, Ala. Const. of 1901. We grant the petition.
After the death of Charles Smith, Sr., his body was sent to the Department's regional laboratory in Mobile for examination. It was stored overnight in a rented refrigeration unit, which malfunctioned. As a result of the malfunctioning, the body substantially deteriorated. Mr. Smith's widow and sons (Bettie Smith, Charles Smith, Jr., and Craig Smith) sued the Department, Dr. Wanger, and several fictitiously named parties. Their complaint alleged: (1) that the defendants had negligently handled Mr. Smith's body; (2) *457 that they had acted recklessly or wantonly in handling his body or had willfully mishandled it; and (3) that the defendants had committed trespass to the personal property of the widow, which she alleged to be the body of Mr. Smith. The complaint sought both compensatory and punitive damages.
The Department and Dr. Wanger moved to dismiss the complaint, on the basis of the defenses of sovereign immunity and qualified immunity. They also moved to stay discovery pending the court's ruling on the motion to dismiss. The circuit court denied both motions. The Department and Dr. Wanger again moved the court to dismiss and moved for a stay of discovery pending the ruling on the second motion to dismiss. The court denied the motion to stay discovery, but has not ruled on the second motion to dismiss the complaint. The Department and Dr. Wanger petitioned the Court of Civil Appeals for a writ of mandamus directing the trial judge to grant their motion to dismiss; that court denied the petition, without opinion, Ex parte Alabama Dep't of Forensic Sciences, (No. 2961088, July 15, 1997) ___ So.2d ___ (Ala. Civ.App.1997) (table). They have now petitioned this Court for a writ of mandamus.

I.
A writ of mandamus is an extraordinary remedy, and it will be "issued only when there is 1) a clear legal right in the petitioner to the order sought; 2) an imperative duty upon the respondent to perform, accompanied by a refusal to do so; 3) the lack of another adequate remedy; and 4) properly invoked jurisdiction of the court." Ex parte United Service Stations, Inc., 628 So.2d 501, 503 (Ala.1993).

II.
Section 14, Ala. Const. of 1901 states: "[T]he State of Alabama shall never be made a defendant in any court of law or equity." Under § 14, the State and its agencies have immunity from suit in any court. Although there are judicially recognized exceptions to the protection afforded by sovereign immunity, see State of Alabama Hwy. Dep't v. Milton Constr. Co., 586 So.2d 872 (Ala.1991), none of those exceptions is invoked by the circumstances of this case. Thus, the Department, as an agency of the State, is immune from the tort liability the plaintiffs seek to impose. Ex parte Franklin County Dep't of Human Resources, 674 So.2d 1277 (Ala.1996); Williams v. John C. Calhoun Community College, 646 So.2d 1 (Ala.1994); Rutledge v. Baldwin County Comm'n, 495 So.2d 49 (Ala.1986). The trial court was without jurisdiction to entertain the action against the Department; thus, as to the Department, the complaint must be dismissed.

III.
State officers and employees, such as Dr. Wanger, sued in their official capacities and individually, are also entitled to the sovereign immunity afforded by § 14, Ala. Const. of 1901, when the action against them is, in effect, an action against the State. Barnes v. Dale, 530 So.2d 770 (Ala.1988); Rutledge, supra; Shoals Community College v. Colagross, 674 So.2d 1311 (Ala.Civ.App. 1995), cert. denied, Ex parte Colagross, 674 So.2d 1315 (Ala.1996). However, the immunity conferred by § 14 is not absolute; it does not apply where the state officer or employee is alleged to have acted illegally, fraudulently, in bad faith, beyond his authority, or under a mistaken interpretation of law, or where the lawsuit seeks to compel the performance of a legal duty or a ministerial act or to enjoin the enforcement of an unconstitutional law, or where the action is brought under the Declaratory Judgment Act. Mitchell v. Davis, 598 So.2d 801 (Ala.1992); Phillips v. Thomas, 555 So.2d 81 (Ala.1989). None of these exceptions to the rule of sovereign immunity applies to this case. Thus, we must go further and determine whether this action is, in effect, an action against the State. In determining whether an action against a state officer or employee is one against the State, this Court must consider the nature of the action and the kind of relief sought. Phillips, supra; DeStafney v. University of Alabama, 413 So.2d 391 (Ala.1981).
The plaintiffs' complaint alleges that Dr. Wanger acted negligently or wantonly and committed a trespass in the performance of his official duties as state medical examiner. Our caselaw holds that a state *458 official or employee is not protected by the State's sovereign immunity when the action alleges such conduct. Phillips, supra; Barnes, supra; DeStafney, supra. Thus, although Dr. Wanger is not protected by absolute immunity from this lawsuit, we must determine whether he is entitled to qualified immunity, also known as "substantive immunity." Qualified immunity shields a state employee from liability if the employee is engaged in a discretionary act, instead of a ministerial one, when the alleged tortious conduct occurs. Defoor v. Evesque, 694 So.2d 1302 (Ala.1997); Taylor v. Shoemaker, 605 So.2d 828 (Ala.1992); Phillips, supra. Whether a state employee's action was discretionary or merely ministerial is a question of law to be decided by the trial court. Defoor, supra; Phillips, supra; Grant v. Davis, 537 So.2d 7 (Ala.1988).
This Court has explained that discretionary functions are characterized by planning and decision-making, while ministerial functions are characterized by operational tasks. Defoor, supra; McDuffie v. Roscoe, 679 So.2d 641 (Ala.1996); Grant, supra.
"Performance of a discretionary function requires an exercise in judgment and choice as to what is proper and just under the circumstances. It involves the exercise of personal deliberation and judgment, which in turn entails examining the facts, reaching reasoned conclusions, and acting on them in a way not specifically directed.... A function is discretionary when it devolves to the officer to determine whether he should perform a certain act and, if so, in what particular way. If a public employee is required to decide and act without fixed or readily ascertainable standards, that act is a discretionary function."
57 Am.Jur.2d Municipal, County, School and State Tort Liability § 119 (1988).
"A ministerial act envisions direct adherence to a governing rule or standard with a compulsory result. It is performed in a prescribed manner without the exercise of judgment or discretion as to the propriety of the action."
Id. at § 120.
The act by Dr. Wanger that the plaintiffs claim was tortious was the use of a rented refrigeration unit to store Mr. Smith's body and other bodies. Although Dr. Wanger had an affirmative duty to store bodies in a certain condition, we conclude that his decision to use a rented refrigeration unit when the Department's facilities were insufficient was a discretionary act rather than a ministerial one and that he is protected by qualified immunity. See McDuffie v. Roscoe, 679 So.2d 641 (Ala.1996); Taylor v. Shoemaker, 605 So.2d 828 (Ala.1992); Grant v. Davis, 537 So.2d 7 (Ala.1988); Barnes v. Dale, 530 So.2d 770 (Ala.1988). Although this Court has noted that "it is the rare case involving the defense of [qualified] immunity that would be properly disposed of by a dismissal pursuant to Rule 12(b)(6), Ala.R.Civ.P.," Patton v. Black, 646 So.2d 8, 10 (Ala.1994), we conclude that Dr. Wanger is clearly entitled to the relief he seeks.

IV.
Because the Department and Dr. Wanger are protected by sovereign immunity and qualified immunity, respectively, the trial court erred in failing to grant their motion to dismiss the complaint for failure to state a claim for which relief could be granted. We grant their petition for a writ of mandamus ordering Judge McDermott to grant their motion to dismiss.
PETITION GRANTED.
HOOPER, C.J., and MADDOX, SHORES, HOUSTON, COOK, BUTTS, and SEE, JJ., concur.
KENNEDY, J., dissents.
