In order to improve the catalytic performance of oxygen reduction reaction (ORR), it is pivotal to increase the density and accessibility of the active sites. Herein, we have developed a template-free melamine-assisted cocalcined strategy to afford Fe-embedded and N-doped carbons (Fe-N-C) with not only high density of atomically dispersed Fe-Nx active sites but also abundant three-dimensional interconnected mesopores by directly pyrolyzing Fe-ZIF-8 covered with a controllable melamine layer. It is demonstrated that the introduction of melamine in the precursor plays a key role in constructing various carbonized products with controllable morphology, porosity, and components. With an optimal mass ratio 1:1 of melamine to Fe-ZIF-8, the resultant Fe@MNC-1 exhibits excellent ORR activity and stability, which exceeds 20 wt % commercial Pt/C catalyst (with a half-wave potential of 0.88 V vs 0.85 V) in an alkaline electrolyte and is even comparable to the commercial Pt/C catalyst (with a half-wave potential of 0.78 V vs 0.80 V) in an acidic electrolyte. To the best of our knowledge, Fe@MNC-1 can be ranked among the best nonprecious metal electrocatalysts for ORR in both alkaline and acidic media. The present synthetic strategy may provide a new opportunity for the design and construction of metal-organic framework-derived nanomaterials with rational composition and a desired porous structure to boost their electrocatalytic performance.