The carbonates in the Middle Devonian Guanwushan Formation (D(2)g) of the western Sichuan Basin are extensively dolomitized. Three types of replacement dolomite can be distinguished: (1) micritic-microcrystalline dolomite (< 30 mu m) with some shale content (Type 1); (2) very fine crystalline dolomite (30-100 mu m) with anhedral-subhedral dolomite crystals (Type 2); and (3) fine crystalline dolomite ( > 100 mu m) with anhedral-subhedral dolomite crystals (Type 3). The anhedral to subhedral fine crystalline crystals in Type 3 dolomite are truncated by a stylolite, which indicates that the formation of Type 3 dolomite most likely occurred simultaneously or predated the stylolite formation. Stratigraphic, petrographic and geochemical data indicate that the Sr-87/Sr-86 ratios (0.70839 to 0.71117) of the D(2)g dolomites, which are higher than those of the contemporaneous seawater (0.70780-0.70830), were affected by the underlying siliciclastic rocks of the Jinbaoshi Formation (D(2)j), Pingyipu Formation (D(1)p) and Silurian strata. The dolomitizing fluids incorporated elemental Sr, which tends to be abundant in crustal fluids. The rare earth element (REE) compositions of the D(2)g dolomites are characterized by enrichment in light REEs and depletion in heavy REEs, Ce, and Eu, indicating that the dolomites of the D(2)g inherited the characteristics of the contemporaneous seawater and formed in a low-temperature, relatively oxic environment. The delta O-18 values of Type 1 and Type 2 dolomites (-6.3 parts per thousand to + 0.43 parts per thousand and -7.2 parts per thousand to - 1.69 parts per thousand, respectively) are slightly higher than those of seawater-derived dolomite, suggesting that these dolomites may be related to the evaporation of seawater during the penecontemporaneous stage. The delta O-18 values of Type 3 dolomite (- 8.32 parts per thousand to - 0.83 parts per thousand) are slightly lower than those of the seawater-derived dolomites, indicating that this dolomite may have formed at a higher temperature during shallow-moderate burial. Type 1 dolomite has higher delta O-18 values, Sr2+ concentrations and total REE (FREE) concentrations and slightly lower Mn2+ concentrations than the other two types of dolomite, suggesting that Type 1 dolomite formed via capillary concentration dolomitization from evaporated seawater. Type 2 dolomite has lower delta O-18 values and Sigma REE contents and slightly higher Mn2+ and Sr2+ concentrations than Type 1 dolomite, suggesting that Type 2 dolomite formed via the seepage-reflux process from denser seawater. Type 3 dolomite has a stylolite, lower delta O-18 values, Sr2+ concentrations and FREE concentrations and slightly higher Mn2+ concentrations and Mg/Ca values, suggesting that Type 3 dolomite formed during shallow-moderate burial.