In the present research, Z-scheme g-C3N4/TiO2 heterojunction composite photocatalysts with varied g-C3N4 content were successfully prepared using the sol-gel technique combined with calcination methods. The morphology, crystallinity, chemical composition, and optical properties of the synthesized catalysts were characterized employing a series of techniques. Sulfamethazine (SMZ) was selected as the model pollutant to evaluate the photocatalytic activity of the prepared catalysts employing a 500 W xenon lamp as the light source to simulate sunlight. The results demonstrated that within 180 min of irradiation, 94.8 % of SMZ was removed by using the optimal photocatalyst (0.4CN/TiO2 composite sample), affording an apparent first-order rate coefficient of 0.0152 min−1 which was 3.8 or 2.0 times as much as that involving single g-C3N4 or TiO2 catalyst, respectively. The effects of catalyst dosage, initial pH, different water matrices, different substrates, and inorganic ions on the performance of 0.4CN/TiO2 photocatalyst were explored. Furthermore, the 0.4CN/TiO2 composite also displayed satisfactory cyclic stability. The results of radical quenching experiments revealed that the key active species in SMZ degradation were hydroxyl radicals (•OH), superoxide radicals (O2•−), and holes (h+). The efficient separation of photo-generated electrons and holes originating in the formation of a Z-scheme g-C3N4/TiO2 heterojunction was evidenced by photoluminescence and electrochemical impedance spectroscopy determination and should be responsible for the enhanced catalytic activity of the 0.4CN/TiO2 sample. In addition, the plausible pathways for the aqueous degradation of SMZ were suggested according to the identified degradation intermediates employing the HPLC/MS technique. In summary, the current research provides a novel insight into the development of Z-scheme heterojunctions in the realm of organic pollutant treatment.