In this work, a nitrogen doped carbon nanotubes encapsulated cobalt nanoparticles (Co@N-CNTs) catalyst was prepared by assembling the precursors of melamine and cobalt nitrate hexahydrate, followed by gradient temperature carbonization in the presence of glucose as a reducing agent. The as prepared Co@N-CNTs composite exhibited electroactivity and long-term stability toward oxygen reduction reaction (ORR) in both alkaline and acidic solutions. It was found that the gradient temperature synthesis and reduction of the gels in the presence of glucose played an important role in the formation of a thin carbon shell on the Co nanoparticles, which protected it from being destroyed during the electrochemical procedures. These processes also facilitated to the ordered arrangement of nitrogen-carbon precursors and the formation of enriched pyridinic, pyrrolic and quaternary nitrogen functional groups that led to the highly activity of Co@N-CNTs. In addition, the catalyst also presented tolerance to methanol oxidation. This synthetic method and mechanism enlighten the future design of state-of-the-art nanostructured materials as an alternation for precious metal based catalysts for highly efficient ORR.