The electrocatalytic nitrogen reduction reaction (eNRR) under ambient conditions is a promising alternative to the Haber–Bosch process, but one of the primary pending issues for the eNRR is the development of efficient and stable electrocatalysts. Herein, we propose to prepare a ZIF-67-derived nitrogen-doped porous carbon-supported Co9S8 nanocomposite achieving the maximum average of 9.80 μg h–1 mgcat–1 NH3 yield and the highest Faradaic efficiency (FE) of 9.89% in 0.1 M Na2SO4. Moreover, Co9S8/NC shows excellent electrocatalytic stability and durability for the eNRR.