A novel peapod-like Ni2P/C nanocomposite is designed and synthesized using NiNH4PO4H2O nanorod sacrificial templates. The nanocomposite exhibits high activity and stability for the hydrogen evolution reaction and an excellent electrochemical performance for use in lithium ion batteries.