The 7-deazapurine derivatives, 2'-deoxy-7-cyano-7-deazaguanosine (dPreQ ) and 2'-deoxy-7-amido-7-deazaguanosine (dADG) are recently discovered DNA modifications encoded by the dpd cluster found in a diverse set of bacteria. Here we identify the genes required for the formation of dPreQ and dADG in DNA and propose a biosynthetic pathway. The preQ base is a precursor that in Salmonella Montevideo, is synthesized as an intermediate in the pathway of the tRNA modification queuosine. Of the 11 genes (dpdA - dpdK) found in the S. Montevideo dpd cluster, dpdA and dpdB are necessary and sufficient to synthesize dPreQ , while dpdC is additionally required for dADG synthesis. Among the rest of the dpd genes, dpdE, dpdG, dpdI, dpdK, dpdD and possibly dpdJ appear to be involved in a restriction-like phenotype. Indirect competition for preQ base led to a model for dADG synthesis in which DpdA inserts preQ into DNA with the help of DpdB, and then DpdC hydrolyzes dPreQ to dADG. The role of DpdB is not entirely clear as it is dispensable in other dpd clusters. Our discovery of a minimal gene set for introducing 7-deazapurine derivatives in DNA provides new tools for biotechnology applications and demonstrates the interplay between the DNA and RNA modification machineries.