A new nanocomposite system based on Ni-doped Mn3O4 nanoparticles embedded in three-dimensional porous carbon nanopipes framework CMK-5 is developed by combination of repeat templating and wet-impregnation techniques to evaluate its performances as anode for rechargeable batteries. The nanocomposite materials are synthesized by varying the Mn3O4 and nickel amounts. Among the nanocomposites, the Ni(5)-Mn3O4(1)@CMK-5 anode exhibits outstanding discharge capacity of 1269 mA h g−1 after 200 cycles and 832 mA h g−1 beyond 500 cycles at 100 and 1000 mA g−1, respectively, for lithium-ion batteries (LIBs). Even at high current of 2000 mA g−1, the electrode possesses the capacity of 669 mA h g−1. When the Ni(5)-Mn3O4(1)@CMK-5 anode is used in sodium-ion batteries (SIBs), it provides remarkable discharge capacities of 490 and 334 mA h g−1 after 500 cycles at 50 and 100 mA g−1, respectively. The excellent electrochemical performances of the Ni(5)-Mn3O4(1)@CMK-5 nanocomposite reveal its promising potentials as anode for LIBs and SIBs.