The CTX-M β-lactamases have emerged as the most widespread extended-spectrum β-lactamases (ESBLs) in Gram-negative bacteria. These enzymes rapidly hydrolyze cefotaxime, but not the related cephalosporin, ceftazidime. ESBL variants have evolved, however, that provide enhanced ceftazidime resistance. We show here that a natural variant at a nonactive site, i.e. second-shell residue N106S, enhances enzyme stability but reduces catalytic efficiency for cefotaxime and ceftazidime and decreases resistance levels. However, when the N106S variant was combined with an active-site variant, D240G, that enhances enzyme catalytic efficiency, but decreases stability, the resultant double mutant exhibited higher resistance levels than predicted on the basis of the phenotypes of each variant. We found that this epistasis is due to compensatory effects, whereby increased stability provided by N106S overrides its cost of decreased catalytic activity. X-ray structures of the variant enzymes in complex with cefotaxime revealed conformational changes in the active-site loop spanning residues 103-106 that were caused by the N106S substitution and relieve steric strain to stabilize the enzyme, but also alter contacts with cefotaxime and thereby reduce catalytic activity. We noted that the 103-106 loop conformation in the N106S-containing variants is different from that of WT CTX-M but nearly identical to that of the non-ESBL, TEM-1 β-lactamase, having a serine at the 106 position. Therefore, residue 106 may serve as a "switch" that toggles the conformations of the 103-106 loop. When it is serine, the loop is in the non-ESBL, TEM-like conformation, and when it is asparagine, the loop is in a CTX-M-like, cefotaximase-favorable conformation.