Cofactor F420 plays critical roles in primary and secondary metabolism in a range of bacteria and archaea as a low-potential hydride transfer agent. It mediates a variety of important redox transformations involved in bacterial persistence, antibiotic biosynthesis, pro-drug activation and methanogenesis. However, the biosynthetic pathway for F 420 has not been fully elucidated: neither the enzyme that generates the putative intermediate 2-phospho-l-lactate, nor the function of the FMN-binding C-terminal domain of the γ-glutamyl ligase (FbiB) in bacteria are known. Here we present the structure of the guanylyltransferase FbiD and show that, along with its archaeal homolog CofC, it accepts phosphoenolpyruvate, rather than 2-phospho-l-lactate, as the substrate, leading to the formation of the previously uncharacterized intermediate dehydro-F 420 -0. The C-terminal domain of FbiB then utilizes FMNH 2 to reduce dehydro-F 420 -0, which produces mature F 420 species when combined with the γ-glutamyl ligase activity of the N-terminal domain. These new insights have allowed the heterologous production of F 420 from a recombinant F 420 biosynthetic pathway in Escherichia coli.