Electrocatalytic nitrate reduction to ammonia (NRA) is a promising strategy for restoring the global nitrogen cycle imbalance while opening up a sustainable avenue for ammonia synthesis. However, the ammonia selectivity and Faradaic efficiency (FE) of electrocatalysts are restrained by the multiple complex reactions during the whole electrolysis process. Herein, we synthesized a series of cobalt phosphide nanowire array catalysts with different phosphidation degrees grown on nickel foam (CoP NWAs/NF). An extremely high nitrate conversion rate of 97.9% as well as ammonia selectivity and FE of ∼ 100% were attained by the optimal CoP NWAs/NF-300 in the NRA reaction, which was much superior to those of counterpart Co3O4 NWAs/NF catalyst and reported cobalt-based catalysts. Several control experiments and density functional theory calculations together unveil the dynamic equilibrium of active hydrogen production and consumption, which is conducive to simultaneously obtaining the super selectivity and FE for ammonia synthesis. This work provides a novel insight for the rational design of high-performance NRA electrocatalyst.