A novel peapod-like Ni2P/C nanocomposite is designed and synthesized using NiNH4PO4H2O nanorods as templates. With enriched nanoporosity and large active surface areas, the peapod-like composites offer superb dual functionality as both electrocatalysts for the hydrogen evolution reaction (HER) and anodes for lithium ion batteries (LIBs). Electrochemical tests demonstrate that the Ni2P/C nanocomposite exhibits an overpotential as low as 60 mV and a notably low Tafel slope of 54 mV dec.(-1). When used as an anode material for lithium-ion batteries, the resulting peapod-like Ni2P/C nanocomposite delivers high specific capacitances of 632 mA h g(-1) at 0.1 A g(-1) and 439 mA h g(-1) at 3 A g(-1), and also exhibits a superior cycling performance, with nearly 100% capacity retention even after 200 charge-discharge cycles at a charge-discharge rate of 0.1 A g(-1). The work demonstrates that the peapod-like materials reported herein are promising materials for electrochemical energy-related applications such as HER and LIBs.