Food processing and refining has dramatically changed the human diet, but little is known about whether this affected the evolution of enzymes in human microbiota. We present evidence that glycoside hydrolase family 70 (GH70) glucansucrases from lactobacilli, synthesizing α-glucan-type extracellular polysaccharides from sucrose, likely evolved from GH13 starch-acting α-amylases, via GH70 4,6-α-glucanotransferases. The crystal structure of a 4,6-α-glucanotransferase explains the mode of action and unique product specificity of these enzymes. While the α-amylase substrate-binding scaffold is retained, active-site loops adapted to favor transglycosylation over hydrolysis; the structure also gives clues as to how 4,6-α-glucanotransferases may have evolved further toward sucrose utilization instead of starch. Further supported by genomic, phylogenetic, and in vivo studies, we propose that dietary changes involving starch (and starch derivatives) and sucrose intake were critical factors during the evolution of 4,6-α-GTs and glucansucrases from α-amylases, allowing oral bacteria to produce extracellular polymers that contribute to biofilm formation from different substrates.