Ru nanoparticles doped in carbon foam were encapsulated in nitrogen-doped graphite carbon materials (Ru-NGC). The resultant Ru-NGC possesses superior hydrogen evolution activity with a small onset potential of 9.5 mV and excellent durability due to the optimized Ru electronic state in nitrogen-doped graphite.