Selenium-impregnated carbon composites were synthesized by infusing Se into mesoporous carbon at a temperature of 600 °C under vacuum. Ring-structured Se8 was produced and confined in the mesoporous carbon, which acts as an electronic conductive matrix. During the electrochemical process in low-cost LiPF6/EC/DEC electrolyte, low-order polyselenide intermediates formed and were stabilized by mesoporous carbon, which avoided the shuttle reaction of polyselenides. Exceptional electrochemical performance of Se/mesoporous carbon composites was demonstrated in both Li-ion and Na-ion batteries. In lithium-ion batteries, Se8/mesoporous carbon composite cathodes delivered a reversible capacity of 480 mAh g–1 for 1000 charge/discharge cycles without any capacity loss, while in Na-ion batteries, it provided initial capacity of 485 mAh g–1 and retained 340 mAh g–1 after 380 cycles. The Se8/mesoporous carbon composites also showed excellent rate capability. As the current density increased from 0.1 to 5 C, the capacity retained about 46% in Li-ion batteries and 34% in Na-ion batteries.