5-Azacytidine is a cytidine-mimic nucleoside containing the 1,3,5-triazine base 5-azacytosine and is currently used to treat myelodysplastic syndrome, a group of blood cancers. 5-Azacytidine was initially reported as a synthetic cytidine analogue before its isolation as a natural product in 1966. Since then, its biosynthesis has remained unexplored, probably because it was regarded as a synthetic analogue. Here we identified the 5-azacytidine biosynthetic gene cluster and revealed unusual catalytic reactions underlying 5-azacytosine biosynthesis through biochemical, structural and density functional theory analyses. AzcE, a guanosine triphosphate (GTP) cyclohydrolase, converts GTP to 2,5,6-triaminopyrimidin-4(1H)-one; AzcA, a cupin domain-containing enzyme, remodels the carbon–nitrogen framework of the pyrimidine into 6-amino-4-oxo-1,4-dihydro-1,3,5-triazine-2-carboxylic acid through selective cleavage and reassembly of the heterocyclic skeleton; and AzcB/C catalyses an unusual thiamine pyrophosphate-dependent decarboxylation at the α‑imino carboxylic acid moiety of the AzcA product to complete 5‑azacytosine biosynthesis. This work uncovers intriguing enzymatic chemistry in the biosynthesis of a long-known therapeutic natural product, highlighting opportunities for discovering enzymatic diversity. Despite decades of clinical use, the biosynthetic origin of 5-azacytidine remained unknown. Now the responsible gene cluster is identified, revealing enzymes that convert guanosine triphosphate into a triazine nucleobase through rare skeletal editing and unconventional thiamine-dependent chemistry.