In this study, cerium carbide embedded in nitrogen-doped carbon (CeCx-NC) has been prepared by a facile pyrolysis of melamine formaldehyde resin containing rare-earth element. The as-prepared CeCx-NC catalyst shows high electrocatalytic activity towards oxygen reduction reaction (ORR) in alkaline electrolyte, with the half wave potential being almost equal to commercial Pt/C, nearly four electron transfer number, good toxicity tolerance durability and cycle stability. This rare-earth metal carbide opens a novel avenue for advanced electrocatalyst.