A novel microporous N-doped carbon confined Se composite was developed as a cathode material for advanced Li-Se batteries. The microporous N-doped carbon was synthesized by carbonization of a ratio-fixed mixture of polypyrrole and KOH. The Se composite cathode is able to deliver a discharge capacity as high as 303 mA h g-1 at 20 C and a reversible capacity of 506 mA h g-1 at 1 C, even after 150 cycles. The superior electrochemical performance can be ascribed to the high electrical conductivity promoted by the N-doping and the unique microporous structure of carbonized polypyrrole, which creates additional active sites for Li-ion storage. More importantly, we used a first-principles calculation to evaluate the influence of heteroatom doping on the electrochemical performance, further confirming that the existence of heteroatoms in the carbon framework greatly facilitates the interaction between carbon and Li2Se, which could well explain the excellent cycling performance and rate capability.