N–N bond formation plays a critical role in the synthesis of organic compounds and has broad applications in producing dyes, pharmaceuticals, and functional materials. However, N–N bond formation is challenging due to the nucleophilicity of nitrogen. Here, we determined the crystal structures of a heme-dependent enzyme, KtzT, which catalyzes the cyclization of l-N5-hydroxyornithine (l-N5-OH-Orn) to yield l-piperazate (l-piz) by linking two intramolecular nitrogen atoms. The complex structure of KtzTC197A with l-N5-OH-Orn reveals the substrate-interaction network, validated through mutagenesis experiments. Notably, the N5 atom of the substrate directly coordinates with the heme iron, precluding oxygen binding. This supports prior knowledge that KtzT catalyzes an oxygen-independent reaction. Intriguingly, the substrate exhibits two distinct conformations in our crystals. Based on the distance between the intramolecular nitrogen atoms and the product accommodation pose in the KtzTC197A/l-piz structure, conformation 2 is likely the productive pose, while the more extended conformation 1 may be a transient state facilitating entry into the catalytic tunnel. A potential catalytic pathway is also proposed. These findings offer structural insights for developing bio- and metal-catalyzed methods for N–N bond formation.