A P-doped CoS2 hybrid (P-doped CoS2-h) was obtained through an effective approach and directly used as a self-supporting nano-electrocatalyst electrode to accelerate electron transfer and enhance HER activity. By utilizing the strong synergistic effect between the hybrid structure and P-doping, the P-doped CoS2-h catalyst exhibits outstanding HER activity in both acidic and alkaline media. It demonstrated an overpotential of 129.4 mV in acidic media and 170 mV in alkaline media to reach 10 mA cm−2. Moreover, this catalyst displayed a long lifetime of 24 h in both acidic and alkaline medium, making it a viable alternative to noble-metal electrocatalysts for water splitting.