AbstractHerein, we present the application of a phosphorus-doped graphitic carbon nitride (P-g-C3N4) for the photodegradation of ciprofloxacin and sulfamethoxazole in water. The photocatalyst was prepared from doping g-C3N4 with phosphorus using different compositions of phosphoric acid (2%, 4%, and 6% w/v). The resultant photocatalysts (2%P-g-C3N4, 4%P-g-C3N4, and 6%P-g-C3N4) were characterized using Fourier transform infrared (FTIR), X-ray diffraction spectroscopy (XRD), scanning electron microscopy–energy-dispersive X-ray (SEM–EDX), and ultraviolet–visible diffuse reflectance mode spectrophotometry (UV–Vis DRS). Photocatalytic degradation studies of the targeted pollutants were performed and monitored using UV–Vis and liquid chromatography coupled with mass spectroscopy (LC–MS). The UV–Vis DRS showed a shift from 2.70 to 2.48 eV in the band gap after doping g-C3N4 with phosphorus. The degradation of sulfamethoxazole by P-g-C3N4 was found to be significantly higher (70%) as compared to g-C3N4 (50%). On the other hand, the removal of ciprofloxacin was found to be 60% for P-g-C3N4, while 50% was found to be the removal efficiency of g-C3N4. The high removal efficiencies were associated with the generated electron holes together with the hydroxyl radicals which played a predominant role in the successful degradation of ciprofloxacin and sulfamethoxazole. Recyclability studies showed that the photocatalyst obtained a high photocatalytic degradation of 65% toward sulfamethoxazole after five cycles. Degradation by-products such as anthralin acid (m/z 307) for ciprofloxacin and monohydroxylated I10 (m/z 269) for sulfamethoxazole were detected using LC–MS. Therefore, P-g-C3N4 serves as a promising photocatalyst for the effective remediation of wastewater generated by pharmaceutical industries.