In this study, an indirect Z-scheme heterojunction photocatalyst was developed by combining TiO2 nanorods, graphene, and Cu3P nanoparticles using a hydrothermal method. This photocatalyst was utilized for the treatment of oil refinery wastewater under simulated sunlight irradiation. The findings indicated that such a heterojunction sample exhibited the improved photocatalytic properties. The enhancement in the photocatalytic activities of these heterojunctions are originated from the reduction in the rate of recombination of the photogenerated charge carriers, enhanced sunlight absorption, and effective generation of reactive species (such as O2⋅ and ⋅OH radicals). Furthermore, Mott-Schottky analysis and radical trapping tests identified hydroxide radicals as the primary active species responsible for the degradation of organic pollutants in the wastewater. An indirect Zscheme charge transfer pathway was found to account for the enhanced photocatalytic properties of the heterojunction samples. In this mechanism, graphene serves as a solid-state electron mediator within the heterojunction structure, facilitating electron transfer between TiO2 and Cu3P. This process leads to improved charge separation, extended lifetimes of electrons and holes, and enhanced photocatalytic efficiency. The synthesized nanocomposite demonstrates satisfactory stability and can be effectively employed for the treatment of oil refinery wastewater.