Vancomycin resistance in Gram-positive bacteria is due to production of cell-wall precursors ending in d-Ala-d-Lac or d-Ala-d-Ser, to which vancomycin exhibits low binding affinities, and to the elimination of the high-affinity precursors ending in d-Ala-d-Ala. Depletion of the susceptible high-affinity precursors is catalyzed by the zinc-dependent d,d-peptidases VanX and VanY acting on dipeptide (d-Ala-d-Ala) or pentapeptide (UDP-MurNac-l-Ala-d-Glu-l-Lys-d-Ala-d-Ala), respectively. Some of the vancomycin resistance operons encode VanXY d,d-carboxypeptidase, which hydrolyzes both di- and pentapeptide. The molecular basis for the diverse specificity of Van d,d-peptidases remains unknown. We present the crystal structures of VanXYC and VanXYG in apo and transition state analog-bound forms and of VanXYC in complex with the d-Ala-d-Ala substrate and d-Ala product. Structural and biochemical analysis identified the molecular determinants of VanXY dual specificity. VanXY residues 110-115 form a mobile cap over the catalytic site, whose flexibility is involved in the switch between di- and pentapeptide hydrolysis. Structure-based alignment of the Van d,d-peptidases showed that VanY enzymes lack this element, which promotes binding of the penta- rather than that of the dipeptide. The structures also highlight the molecular basis for selection of d-Ala-ending precursors over the modified resistance targets. These results illustrate the remarkable adaptability of the d,d-peptidase fold in response to antibiotic pressure via evolution of specific structural elements that confer hydrolytic activity against vancomycin-susceptible peptidoglycan precursors.