Herein, we introduce a peapod-like composite with Ni12P5 nanoparticles encapsulated in carbon fibers as the enhanced anode in Li-ion batteries for the first time. In the synthesis, NiNH4PO4⋅H2O nanorods act as precursors and sacrificial templates, and glucose molecules serve as the green carbon source. With the aid of hydrogen bonding between the precursor and carbon source, a polymer layer is hydrothermally formed and then rationally converted into carbon fibers upon inert calcination at elevated temperatures. Meanwhile, NiNH4PO4⋅H2O nanorods simultaneously turn into Ni12P5 nanoparticles encapsulated in carbon fibers by undergoing a decomposition and reduction process induced by high temperature and the carbon fibers. The obtained composite performs excellently as a Li-ion batteries anode relative to pure-phase materials. Specific capacity can reach 600 mAh g−1 over 200 cycles, which is much higher than that of isolated graphitized carbon or phosphides, and reasonably believed to originate from the synergistic effect based on the combination of Ni12P5 nanoparticles and carbon fibers. Due to the benignity, sustainability, low cost, and abundance of raw materials of the peapod-like composite, numerous potential applications, in fields such as optoelectronics, electronics, specific catalysis, gas sensing, and biotechnology can be envisaged.