Rationally designed structures and elements are important for the construction of effective electrocatalysts for water splitting. Herein, we developed an ultrathin hierarchical P-doped MoS2/Ni3S2 heterostructure on nickel foam (NF) by a one-pot synthesis. Owing to its optimized electronic structure configuration and hierarchical structure with plenty of active sites, the optimized catalyst P1.0-doped MoS2/Ni3S2/NF showed promising activity for both hydrogen evolution reaction and oxygen evolution reaction in an alkaline medium requiring an overpotential of, respectively, 0.449 and 0.239 V at 100 mA cm–2. Furthermore, the P1.0–MoS2/Ni3S2/NF electrode was applied for overall water splitting using a two-electrode system. The electrolyzer achieved low cell voltages of 1.50 and 1.65 V at current densities of, respectively, 20 and 40 mA cm–2 with excellent stability over 60 h when compared with previously reported Ni3S2-based materials. The results obtained in this work highlight the prime combination of doping and interface engineering for the design of advanced materials in electrocatalysis.