A novel one-step, one-pot strategy to synthesize Co2P encapsulated N,P dual doped carbon nanotubes (Co2P/NPCNTs) is developed via a g-C3N4 intermediated approach. The method uses readily available, inexpensive precursors without involving toxic phosphine gas (PH3) during the phosphidation process. Moreover, the CNTs are synthesized and doped in situ without the aid of any external carbon additives. The morphology and structure were characterized by field-emission scanning electron microscopy (FESEM), transmission electron microscopy (TEM), X-ray diffraction (XRD), Raman spectroscopy and X-ray photoelectron spectroscopy (XPS). The as-prepared Co2P/NPCNTs were then for the first time demonstrated to be an electrochemical sensor for the enzymeless detection of glucose. The Co2P/NPCNT-modified electrode exhibits a quick response and good linearity (R2 = 0.997) up to 7 mM with a high sensitivity and a low detection limit (LOD) of 338.8 μA mM−1 cm−2 and 0.88 μM, respectively, towards glucose, selectively in the presence of various endogenous interfering agents such as D-sucrose, D-mannose, L-cysteine, urea etc. with a good long-term stability. When applied as an electrocatalyst for the oxygen evolution reaction (OER), Co2P/NPCNT delivers a current density of 10 mA cm−2 at an overpotential of 370 mV with a Tafel slope of only 53 mV dec−1, outperforming even the state-of-the-art RuO2 while maintaining excellent long-term durability.