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 substrates. The molecular basis for the diverse specificity of Van D,D-peptidases remains unknown. Here we present the crystal structures of VanXYC and VanXYG in apo and transition state analog-bound forms and of VanXYC in complex with its substrate (D-Ala-D-Ala) and the product (D-Ala). Our structural and biochemical analysis identified the mobile cap formed by VanXYC residues 110 to 115 over the catalytic site as the key structural element involved in the switch between di- and penta-peptide hydrolysis. The structure of a VanY-like enzyme, BaLdcB, from Bacillus anthracis showed that the active site of VanY peptidases lacked this element featuring a molecular architecture in line with preference for larger substrates. Presented structural data also highlight the molecular basis for selection of D-Ala-terminating peptidoglycan precursors over the modified Van-resistant components. These results illustrate the remarkable adaptability of D,D-peptidase fold in response to antibiotic pressure via evolution of specific structural elements that confer bisubstrate hydrolytic activity.