Membrane-embedded prenyltransferases from the UbiA family catalyze the Mg2+-dependent transfer of a hydrophobic polyprenyl chain onto a variety of acceptor molecules and are involved in the synthesis of molecules that mediate electron transport, including Vitamin K and Coenzyme Q. In humans, missense mutations to the protein UbiA prenyltransferase domain-containing 1 (UBIAD1) are responsible for Schnyder crystalline corneal dystrophy, which is a genetic disease that causes blindness. Mechanistic understanding of this family of enzymes has been hampered by a lack of three-dimensional structures. We have solved structures of a UBIAD1 homolog from Archaeoglobus fulgidus, AfUbiA, in an unliganded form and bound to Mg2+ and two different isoprenyl diphosphates. Functional assays on MenA, a UbiA family member from E. coli, verified the importance of residues involved in Mg2+ and substrate binding. The structural and functional studies led us to propose a mechanism for the prenyl transfer reaction. Disease-causing mutations in UBIAD1 are clustered around the active site in AfUbiA, suggesting the mechanism of catalysis is conserved between the two homologs.