The heterocycle 1,2,3-triazole is among the most versatile chemical scaffolds and has been widely used in diverse fields. However, how nature creates this nitrogen-rich ring system remains unknown. Here, we report the biosynthetic route to the triazole-bearing antimetabolite 8-azaguanine. We reveal that its triazole moiety can be assembled through an enzymatic and non-enzymatic cascade, in which nitric oxide is used as a building block. These results expand our knowledge of the physiological role of nitric oxide synthase in building natural products with a nitrogen-nitrogen bond, and should also inspire the development of synthetic biology approaches for triazole production.