In the Yan'an gas field, southeast of Ordos Basin, the discovered natural gas reserves are 114 billion cubic meters. Highly productive gas reservoirs were formed in paleokarst. By using 164 samples from 27cores, the geochemical study of diagenetic evolution was carried out, and the relationship between different diagenesis environments was discussed by using scanning electron microscopy, carbon and oxygen isotope, and isotopic and fluid inclusion microthermometric observations. Results show that the lithology of reservoir is anhydrite-bearing mud powder crystal dolomite, powder crystal dolomite, and karst breccia dolomite; the filling includes dolomite, calcite, anhydrite, quartz, fluorite, and clay minerals; delta C-13 (parts per thousand PDB) value is between -6.31 parts per thousand and 1.01 parts per thousand, delta O-18 (parts per thousand PDB) value ranges from -11.36 parts per thousand to -6.54 parts per thousand, and the Sr-87/Sr-86 value ranges from 0.7077 to 0.7081. The overall carbon isotope of Majiagou Formation decreases first and then increases, and the strontium isotope evolution curve generally increases first and then decreases, indicating that the water environment of Majiagou Formation experienced a relatively high salinity concentration period and a relative desalinization period during deposition. The stratigraphic development shows a cyclical trend, responding to the multistage transgression and regression process. The homogenization temperature of fluid inclusions is 70-100 degrees C, salinity is 0-3.5%, homogenization temperature of fluid inclusions is 70-100 degrees C, salinity is >3.5%, homogenization temperature of fluid inclusions is 100-160 degrees C, salinity is 0-3.5%, homogenization temperature of fluid inclusions is 100-160 degrees C, salinity is >3.5%, homogenization temperature of fluid inclusion temperature is 160-200 degrees C, and salinity is >3.5%, indicating that the fluid source in the sedimentation and diagenesis process is seawater, atmospheric freshwater, hydrocarbon fluid, and deep thermal fluid. The diagenetic environments are divided into marine diagenetic environments, metric freshwater diagenetic environments, and burial diagenetic environments.