Trehalose is a nonreducing disaccharide that plays a major role in many organisms, most notably in survival and stress responses. In Mycobacterium tuberculosis, it plays a central role as the carbohydrate core of numerous immunogenic glycolipids including "cord factor" (trehalose 6,6'-dimycolate). The classical pathway for trehalose synthesis involves the condensation of UDP-glucose and glucose-6-phosphate to afford trehalose-6-phosphate, catalyzed by the retaining glycosyltransferase OtsA. The configurations of two anomeric positions are set simultaneously, resulting in the formation of a double glycoside. The three-dimensional structure of the Escherichia coli OtsA, in complex with both UDP and glucose-6-phosphate, reveals the active site at the interface of two beta/alpha/beta domains. The overall structure and the intimate details of the catalytic machinery reveal a striking similarity to glycogen phosphorylase, indicating a strong evolutionary link and suggesting a common catalytic mechanism.