The identification of geologic fluids and related fluid–rock interactions during diagenesis is the subject of much research in sedimentary petrology. Authigenic calcite potentially provides a record of geologic fluids and it occurs heterogeneously in the Upper Permian Wuerhe Formation (P3w) in the Shawan Sag, Junggar Basin, which has a complex history of geologic fluid activity. This provides an ideal opportunity to study the effectiveness of authigenic calcite in tracing fluids. We conducted optical, cathodoluminescence (CL), and scanning electron microscopic observations, as well as the major and trace element and stable carbon and oxygen isotopes of authigenic calcite. The results show that three generations of calcite were precipitated in the P3w Formation, and the diagenetic fluid was affected to varying degrees by paleo-meteoric water and hydrocarbon-bearing fluids. During early diagenesis, diagenetic fluid with low Mn contents precipitated the amorphous early-stage calcite (dark red in CL images, MnO <1.5%, δ13C = −8.6‰ to 2.1‰, VPDB). Its carbon source was mainly meteoric CO2. During mesodiagenesis, the limited hydrocarbon emplacement during the Middle Jurassic enriched the pore fluids in Mn and 13C-depleted organic derived CO2, subsequently precipitating the late-stage sparry calcite I (orange in CL images with MnO of 2.5%–4% and δ13C of −14.5‰ to −8.1‰). The carbon in this calcite came from the dissolution of early-stage calcite and CO2 generated by decarboxylation of organic acids. During the Early Cretaceous, large-scale hydrocarbon charging occurred and the pore fluids were further enriched in Mn and organic derived CO2, eventually precipitating the late-stage sparry calcite II (bright yellow in CL images with MnO of >4% and δ13C of −25.7‰ to −14.9‰). Its carbon source was mainly CO2 produced by the decarboxylation of organic acids. The precipitation of abundant late-stage sC-depleted calcite suggests that the hydrocarbons were oxidized to organic acids in the reservoir. The two periods of hydrocarbon charging caused the dissolution of laumontite and the early-stage calcite, forming secondary minerals and dissolution pores, which increased the porosity and permeability of the rock. Therefore, authigenic calcite is a useful tracer of fluid properties, fluid–rock interactions, and alteration processes in petroliferous basins.