The hydrogen evolution reaction (HER) is a crucial step in electrochemical water splittingand demands an efficient, durable and cheap catalyst if it is to succeed in real applications.For an energy-efficient HER, a catalyst must be able to trigger proton reduction withminimal overpotential and have fast kinetics. The most efficient catalysts in acidic mediaare platinum-based, as the strength of the Pt–H bond is associated with the fastest reactionrate for the HER. The use of platinum, however, raises issues linked to cost and stability innon-acidic media. Recently, non-precious-metal-based catalysts have been reported, butthese are susceptible to acid corrosion and are typically much inferior to Pt-basedcatalysts, exhibiting higher overpotentials and lower stability. As a cheaper alternative toplatinum, ruthenium possesses a similar bond strength with hydrogen (∼65 kcal mol–1), buthas never been studied as a viable alternative for a HER catalyst. Here, we report aRu-based catalyst for the HER that can operate both in acidic and alkaline media. Ourcatalyst is made of Ru nanoparticles dispersed within a nitrogenated holey two-dimensionalcarbon structure (Ru@C2N). The Ru@C2N electrocatalyst exhibits high turnover frequenciesat 25 mV (0.67 H2 s−1 in 0.5 M H2SO4 solution; 0.75 H2 s−1 in 1.0 M KOH solution) andsmall overpotentials at 10 mA cm–2 (13.5 mV in 0.5 M H2SO4 solution; 17.0 mV in 1.0 MKOH solution) as well as superior stability in both acidic and alkaline media. Theseperformances are comparable to, or even better than, the Pt/C catalyst for the HER.