The scalable and sustainable production of hydrogen fuel through water splitting demands efficient and robust Earth-abundant catalysts for the hydrogen evolution reaction (HER). Building on promising metal compounds with high HER catalytic activity, such as pyrite structure cobalt disulphide (CoS 2), and substituting non-metal elements to tune the hydrogen adsorption free energy could lead to further improvements in catalytic activity. Here we present a combined theoretical and experimental study to establish ternary pyrite-type cobalt phosphosulphide (CoPS) as a high-performance Earth-abundant catalyst for electrochemical and photoelectrochemical hydrogen production. Nanostructured CoPS electrodes achieved a geometrical catalytic current density of 10 mA cm at overpotentials as low as 48mV, with outstanding long-term operational stability. Integrated photocathodes of CoPS on n -p-p silicon micropyramids achieved photocurrents up to 35 mA cm at 0 V versus the reversible hydrogen electrode (RHE), onset photovoltages as high as 450 mV versus RHE, and the most efficient solar-driven hydrogen generation from Earth-abundant systems.