Shikimate dehydrogenase catalyzes the fourth step of the shikimate pathway, the essential route for the biosynthesis of aromatic compounds in plants and microorganisms. Absent in metazoans, this pathway is an attractive target for nontoxic herbicides and drugs. Escherichia coli expresses two shikimate dehydrogenase paralogs, the NADP-specific AroE and a putative enzyme YdiB. Here we characterize YdiB as a dual specificity quinate/shikimate dehydrogenase that utilizes either NAD or NADP as a cofactor. Structures of AroE and YdiB with bound cofactors were determined at 1.5 and 2.5 A resolution, respectively. Both enzymes display a similar architecture with two alpha/beta domains separated by a wide cleft. Comparison of their dinucleotide-binding domains reveals the molecular basis for cofactor specificity. Independent molecules display conformational flexibility suggesting that a switch between open and closed conformations occurs upon substrate binding. Sequence analysis and structural comparison led us to propose the catalytic machinery and a model for 3-dehydroshikimate recognition. Furthermore, we discuss the evolutionary and metabolic implications of the presence of two shikimate dehydrogenases in E. coli and other organisms.