More than 80 partially to completely dolomitized buildups of Middle Devonian Keg River Formation occur in the Rainbow sub-basin of northwestern Alberta. In six buildups (A, B, E, F, G, and Tehze), four petrographic types of dolomites are identified: gray, fine crystalline dolomite; floating dolomite rhombs/patches; matrix dolomite; and saddle dolomite. The petrographic and geochemical data indicate that these dolomites probably formed in three principle stages of dolomitization during progressive burial. Gray, fine crystalline dolomite (less than 1% of total dolomite by volume) is interpreted as penecontemporaneously dolomitized lime muds by either normal marine waters or evaporitic brines during early exposure. The following evidence suggests that this dolomite probably formed early: 1) it usually occurs in fractures and breccias presumably related to the early exposure of the buildups; 2) it is absent in rugs and molds that formed in the subsurface environment; and 3) locally, clasts of gray, fine crystalline dolomite are embedded in marine limestones. Rhomb/patch dolomite is the major type of dolomite in dolomitic limestones and is widespread throughout the limestone buildups. Matrix dolomite is fabric destructive and is most abundant in the dolostone buildups. Both these dolomites probably formed during shallow to intermediate burial because they 1) postdate stylolites, 2) are widespread throughout the buildups and crosscut various facies, and 3) have light oxygen isotope compositions and low Sr but high Fe and Mn concentrations. Dolomitizing fluids for dolomite rhombs/patches and matrix dolomites were possibly derived from 1) mechanical compaction, 2) dehydration of the adjacent Muskeg gypsum at relatively shallow burial depths, and 3) intermediate-depth basinal fluids conducted updip along porous and permeable conduits. During Devonian and carly Carboniferous times, compaction fluids were probably responsible for the early dolomite rhombs and patches. However, the main phase of matrix dolomitization took place later, probably during Late Mississippian to Jurassic time when the east side of the basin was intermittently tilted and uplifted, causing updip flow of intermediate-depth basinal brines. Saddle dolomite occurs as late-stage vug and fracture fillings. It is most depleted in delta 18 O but most enriched in Mn and Fe, suggesting precipitation during deeper burial from warm basinal fluids. These fluids were expelled during Upper Cretaceous sedimentary and tectonic loading of the western side of the basin and then moved up the east side of the basin along existing platform, fault, and fracture conduits. The source of the Mg is uncertain. Some or most of the Mg may have resulted from chemical compaction of the earlier matrix dolomite.