Fe and N dual-doped mesoporous carbon catalyst demonstrated superior catalytic activity than Pt catalyst for both oxygen reduction and oxidation reactions in alkaline electrolyte. The catalyst was synthesized through a novel simple sublimation and capillary assisted nanocasting method. Using the method, multiple transition metal and nitrogen dual-doped mesoporous carbon electrocatalysts were also successfully made. It was believed that the excellent catalytic activity was resulted from the synergistic effects of highly active metal-nitrogen species, mesoporous structure, large interfacial surface and excellent conductivity. The present synthetic strategy offers a new insight into preparation of heteroatom-doped electrocatalysts with promising applications in metal-air batteries, fuel cells, and supercapacitors as well.