Authigenic carbonate cement is one of the most abundant diagenetic minerals in sandstone reservoirs. Determining its origin and distribution may provide useful information for understanding the sandstone reservoir quality. In this study, we report results from a suite of analytical techniques to investigate the origin and evolution of carbonate cements in the third member of the Shahejie Formation in the Bohai Bay Basin. Our data indicate that the carbonate cements mainly occur in three phases: the early-phase calcite, late-phase ferroan calcite, and late-phase ferroan dolomite and/or ankerite. The early-phase calcites show depleted δ18O of the early-phase calcite (−11.8% to −7.8%), suggesting an 18O-depleted fluid origin from the mixing between lacustrine and meteoric waters. They were precipitated earlier than the quartz overgrowth at 40°C–63°C based on the oxygen isotope. The late-phase calcites were precipitated at 70°C–115°C, and they originated from water-rock interaction modified pore water at the same time or later than feldspar leaching. They show a lower average δ13C value (1.27%) than the early-phase calcite (1.65%), indicating that the interbedded shales within the sandstones most likely provided the required components for the precipitation of the late-phase calcite. Also, some Fe2+ was released during the organic acid release and then precipitated the late-phase ferroan calcites. The late-phase ferroan dolomite and/or ankerite were precipitated at 90°C–137°C in a deep diagenetic condition. They show depleted δ13C values (mean ), and the carbons were mainly sourced from the thermal decarboxylation of organic matter and lacustrine carbonate. The early-phase calcite inhibits compaction while filling the pores, and the dissolution of ferroan calcite cements was the main reason for the development of secondary pores in the sandstone reservoirs. The late-phase ankerite reduces the reservoir porosity.