The mesoporous 3D/2D NiCoP/g-C3N4 heterostructure is fabricated by embedding NiCoP nanoclusters on the surfaces of g-C3N4 nanosheets, which exhibit more outstanding photocatalytic H2 production activity than g-C3N4 modified with Pt and other similar phosphides. The highest H2 production rate over NiCoP/g-C3N4 heterostructures reaches up to about 2.27 times than that of Pt/g-C3N4 under visible light, and meanwhile, the NiCoP/g-C3N4 heterostructure can maintain a continuously stable H2 production rate during long cyclic running of 15 times in a total of 60 h. The structure and properties investigations reveal that the splendid H2 production activity and stability derive from the formed dual Co–N and Ni–N bonding states between 3D NiCoP nanoclusters and 2D g-C3N4 nanosheets that can efficiently facilitate the transfer and separation of charge carriers and improve the interaction at heterointerfaces.