Ab initio electronic structure calculations reveal that interstitial 2p elements (B, C, and N) have dramatic effects on the structural stability and intrinsic magnetic properties of L10-phase FeNi. Among the 3 possible interstitial impurities, only the B improves the L10-phase stability of FeNi and enhances its uniaxial magnetic anisotropy (0.7 MJ m−3) up to 2.6 MJ m−3. The underlying mechanism is elucidated in terms of single-particle energy spectra analyses along with atom- and orbital-resolved magnetocrystalline anisotropy energy, where both the Fe and Ni 3d level changes induced by charge rearrangement and 2p-3d hybridization are responsible. These findings point toward feasibility of enhancing the structural stability and energy product of 3d-only magnetic metals through the interstitial doping with 2p nonmetal elements.