Three-dimensional (3D) carbon foams (CF) surrounded by carbon nanotubes (CNTs) and Co-Co3O4 nanoparticles (NPs) (CF@Co-Co3O4/CNT) nanocomposites were prepared by a two-step method for stable lithium-ion batteries (LIBs). The low-cost melamine foams pre-soaked in cobalt nitrate solution were firstly carbonized under nitrogen atmosphere to form 3D CF surrounded by a large number of CNTs and Co NPs (CF@Co/CNT). Subsequently, the CF@Co/CNT was transformed into CF@Co-Co3O4/CNT nanocomposites by calcination in air. Here, Co NPs, CNT and 3D CF all improved the electrical conductivity of CF@Co-Co3O4/CNT nanocomposites. In addition, a large number of uniformly-dispersed small Co3O4 NPs effectively increased Li+ storage capacity of nanocomposites. At the same time, the 3D macroporous carbon frameworks surrounded by CNT could also relieve the volume deformation of Co3O4 NPs to some extent. When it was employed as anode materials for LIBs, CF@Co-Co3O4/CNT nanocomposites exhibited the stable reversible capacities of about 500 mAh g−1 at 0.5 A g−1, larger than that of commercial graphite and some other Co-based materials. The two-step preparation method was simple and convenient for large-scale production.