Chirality plays a critical role in the biochemistry of life and often only one enantiomeric series is observed (homochirality). Only a few natural products have been obtained as racemates, e.g. the signalling molecule valdiazen produced by Burkholderia cenocepacia H111. In this study, we investigated the ham biosynthetic gene cluster and discovered that both the enantiomerically pure (R)-fragin and the racemic valdiazen result from the same pathway. This stereodivergence is based on the unusual heterocyclic intermediate dihydrosydnone N-oxide, as evident from gene knockout, stable isotope feeding experiments, and mass spectrometry experiments. Both non-enzymatic racemisation via keto-enol tautomerisation and enzyme-mediated dynamic kinetic resolution were found to be crucial to this stereodivergent pathway. This novel mechanism underpins the production of configurationally and biologically distinct metabolites from a single gene cluster. Our findings highlight the intricate design of an intertwined biosynthetic pathway and provide a deeper understanding of microbial secondary metabolism related to microbial communication.