Gray-black kaolinitic claystones of industrial value are abundant in Upper Carboniferous–Lower Permian coal-bearing strata of the Datong Coalfield of northern China. The main types are tonsteins and cryptocrystalline kaolinitic claystones, distinguished by the thinness and greater crystallinity of kaolinite in the former and by the presence of detrital illite and authigenic pyrite in the latter. In order to determine the formation history of these two types of kaolinitic claystone, the petrological, mineralogical, and geochemical characteristics of borehole samples from the Upper Carboniferous Taiyuan Formation which comprises siliciclastics and coal seams deposited in a coastal environment, were analyzed. In addition to kaolinite, the claystones contain subordinate illite, quartz, pyrite, anatase, feldspar, siderite, and calcite. The tonsteins and cryptocrystalline kaolinitic claystones have different sources, as shown by petrographic data, elemental ratios, and chondrite-normalized rare earth element (REE) patterns. The volcanic origin of the tonsteins is revealed by an abundance of volcanic quartz and vitric fragments as well as Al2O3/TiO2, Zr/Hf, and Nb/Ta ratios consistent with a felsic igneous source. Their REE fraction was derived from feldspars or micas of the parent rocks, and the fraction decreased with alteration of these minerals to kaolinite. The sedimentary origin of the cryptocrystalline kaolinitic claystones is revealed by an abundance of detrital quartz and illite grains derived from either granite or sedimentary upper crust, and by the total REE contents (ΣREE) and (La/Yb)N values which are consistent with granitic material. Their depositional environment was in a transitional (coastal) setting (as shown by intermediate Sr/Ba ratios) hosting an open acidic hydrologic system (as shown by high chemical index of alteration (CIA) values indicative of intensive chemical weathering) that was suboxic to anoxic (as shown by high U/Th ratios and trace-metal enrichment factors). The present chemistry of these claystones was thus controlled by a combination of parent rock type and diagenetic alteration.