Despite being technically possible, the hydrogen production by means of electrocatalytic water splitting is still practically unreachable mainly because of the lack of inexpensive and high active catalysts. Herein, a novel and facile approach by melamine polymerization, exfoliation and Co(2+)-assisted thermal annealing is developed to fabricate Co nanoparticles embedded in bamboo-like and nitrogen-rich carbonitride nanotubes (Co@NCN). The electronic interaction between the embedded Co nanoparticles and N-rich carbonitride nanotubes could strongly promote the HER performance. The optimized Co@NCN-800 exhibits outstanding HER activity with an onset potential of -89 mV (vs RHE), a large exchange current density of 62.2 μA cm(-2), and small Tafel slope of 82 mV dec(-1), as well as excellent stability (5000 cycles) in acid media, demonstrating the potential for the replacement of Pt-based catalysts. Control experiments reveal that the superior performance should be ascribed to the synergistic effects between embedded Co nanoparticles and N-rich carbonitride nanotubes, which originate from the high pyridinic N content, fast charge transfer rate from Co particles to electrodes via electronic coupling, and porous and bamboo-like carbonitride nanotubes for more active sites in HER.