Court, Lloyd, and Salvatore brought actions under 42 U.S.C. § 1983 against Sheriff Fairbanks and Hall County to recover damages based upon their claims that constitutional violations occurred when they were deprived of the opportunity to exercise during pretrial detention in the county jail. The district court granted separate motions filed by the sheriff and the county to dismiss for failure to state a claim upon which relief can be granted pursuant to Federal Rule of Civil Procedure 12(b)(6). The sheriff’s motion was supported by affidavits. This appeal involves a challenge only to the district court’s dismissal of the action against the sheriff on the ground that he was “entitled to qualified immunity *1172in this case.” Without expressing any opinion concerning the merits of the qualified immunity issue, and without prejudice to any party’s right subsequently to raise this issue in a motion for summary judgment, we vacate the district court’s order granting the sheriff’s motion to dismiss.
Under Rule 12(b) of the Federal Rules of Civil Procedure, a motion to dismiss for failure to state a claim upon which relief can be granted must be treated as a motion for summary judgment, and disposed of as provided in Rule 56, when matters outside the pleading are presented to and not excluded by the district court. Fed.R.Civ.P. 12(b); see Carter v. Stanton, 405 U.S. 669, 671, 92 S.Ct. 1232, 1234, 31 L.Ed.2d 569 (1972); Woods v. Dugan, 660 F.2d 379, 380-81 (8th Cir.1981). Accordingly, if the defendant files an affidavit in support of a Rule 12(b)(6) motion to dismiss, the district court must treat the motion as one for summary judgment unless it decides to exclude the affidavit in considering the motion. Id. at 380. In this case, however, the district court did not exclude the sheriff’s affidavits from its consideration of the motion to dismiss. Indeed, the district court referred to one of the sheriff’s affidavits in its memorandum. As a consequence, the motion to dismiss was in effect converted into a motion for summary judgment. See id. at 380-81.
We do not believe that this is a case in which the conversion should have occurred. The sheriff’s affidavits are so meager that we are unable fairly to discern the factual basis which supports the sheriff’s claim of immunity. Faced as it was with skimpy affidavits, the district court should have chosen the option provided by Rule 12(b), disregarded the extrinsic material, and decided the motion to dismiss based on the amended complaint alone. See Ware v. Associated Milk Producers, Inc., 614 F.2d 413, 414-15 (5th Cir.1980).
Once the district court decided not to exclude the extrinsic material, however, it was essential that the court give the parties notice of the changed status of the motion and a “reasonable opportunity to present all materials made pertinent to such a motion by Rule 56.” Fed.R.Civ.P. 12(b); see Woods v. Dugan, supra, 660 F.2d at 381; Jensen v. Klecker, 599 F.2d 243, 245 (8th Cir.1979); Winfrey v. Brewer, 570 F.2d 761, 764 (8th Cir.1978); Ailshire v. Darnell, 508 F.2d 526, 527-28 (8th Cir.1974).
In the case before us the district court did not give adequate notice of the changed status of the motion and a reasonable opportunity to respond to the sheriff’s affidavits. The sheriff’s motion to dismiss with supporting affidavits was filed February 15, 1983. On March 11 an order was entered which scheduled a pretrial conference for September 21 and fixed a trial date for October 3. This order certainly gave counsel for the pretrial detainees a reasonable expectation, absent notice to the contrary, that his clients would have a trial on the merits. Subsequently, on May 6, and without any indication it was going to consider matters beyond the amended complaint on the sheriff’s motion to dismiss, the district court granted the sheriff’s motion. Under these circumstances we believe the pretrial detainees were taken by surprise, and were thus not given a fair opportunity to controvert the sheriff’s affidavits. We require adherence to the notice requirements of Federal Rule of Civil Procedure 56(c) in these circumstances. See Jensen v. Klecker, supra, 599 F.2d at 245; Winfrey v. Brewer, supra, 570 F.2d at 764.
We vacate the district court’s order and remand to the district court for further proceedings.