Exploring efficient and stable halide perovskite-based photocatalysts is a great challenge due to the balance between the photocatalytic performance, toxicity, and intrinsic chemical instability of the materials. Here, the environmentally friendly lead-free perovskite Cs2AgBiBr6 confined in the mesoporous TiO2 crystal matrix has been designed to enhance the charge carrier extraction and utilization for efficient photocatalytic rifampicin degradation. The as-prepared Cs2AgBiBr6/TiO2 catalyst was stable in air for over 500 days. An S-scheme heterojunction was formed between the (004) plane of Cs2AgBiBr6 and the (101) plane of TiO2 through the Bi-O-Br bonds. The built-in electric field at the interface efficiently promoted the photoinduced charge separation and carrier extraction. The Cs2AgBiBr6/TiO2-200 showed a 92.83% degradation efficiency of rifampicin within 80 min under simulated sunlight illumination (AM 1.5G 100 mW cm-2). This work offers an effective way for the construction of halide perovskite-based photocatalysts with high photocatalytic performance, good stability, and low toxicity simultaneously.