The prohibitive cost of platinum for catalyzing the cathodic oxygen reduction reaction (ORR) has hampered the widespread use of polymer electrolyte fuel cells. We describe a family of non-precious metal catalysts that approach the performance of platinum-based systems at a cost sustainable for high-power fuel cell applications, possibly including automotive power. The approach uses polyaniline as a precursor to a carbon-nitrogen template for high-temperature synthesis of catalysts incorporating iron and cobalt. The most active materials in the group catalyze the ORR at potentials within ~60 millivolts of that delivered by state-of-the-art carbon-supported platinum, combining their high activity with remarkable performance stability for non-precious metal catalysts (700 hours at a fuel cell voltage of 0.4 volts) as well as excellent four-electron selectivity (hydrogen peroxide yield <1.0%).