As sustainable energy becomes a major concern for modern society, renewable and clean energy systems need highly active, stable, and low-cost catalysts for the oxygen evolution reaction (OER). Mesoporous materials offer an attractive route for generating efficient electrocatalysts with high mass transport capabilities. Herein, we report an efficient hard templating pathway to design and synthesize three-dimensional (3-D) mesoporous ternary nickel iron nitride (Ni3FeN). The as-synthesized electrocatalyst shows good OER performance in an alkaline solution with low overpotential (259 mV) and a small Tafel slope (54 mV dec−1), giving superior performance to IrO2 and RuO2 catalysts. The highly active contact area, the hierarchical porosity, and the synergistic effect of bimetal atoms contributed to the improved electrocatalytic performance toward OER. In a practical rechargeable Zn–air battery, mesoporous Ni3FeN is also shown to deliver a lower charging voltage and longer lifetime than RuO2. This work opens up a new promising approach to synthesize active OER electrocatalysts for energy-related devices.