Molecules with nitrogen–nitrogen (N–N) bonds include diverse specialized metabolites from nature, but little is known about the underlying enzymatic mechanisms that have evolved for N–N bond formation. To directly form a single N(sp3)–N(sp3) bond, enzymes must reverse the typical nucleophilicity of one nitrogen. Here we report the structure of PipS, a haem-dependent enzyme that catalyses