Antibiotic resistance has become a critical public health problem, rendering many antibiotics ineffective. In particular, the evolution of extended-spectrum β-lactamases (ESBLs) threatens β-lactams, the cornerstone of bacterial infection treatment. We investigated the evolution of Escherichia coli TEM-1 β-lactamase into ESBLs by constructing a combinatorially complete library of all 55,296 TEM-1 variants from 18 clinical mutations across 13 residues. We obtained over 9,000,000 fitness measurements under native (ampicillin) and non-native (aztreonam) selection. Graph-theoretic and epistatic analyses revealed that ampicillin selection produced weak epistasis and predictable evolutionary trajectories, whereas aztreonam selection induced extensive higher-order epistasis, increasing phenotypic unpredictability. Machine learning identified interpretable epistatic rules shaping these landscapes. Evolutionary statistics, including direct coupling analysis and latent generative landscapes, showed that top-performing ESBL variants followed conserved epistatic patterns observed in natural β-lactamases. Our integrated experimental–computational framework provides a foundation for predicting ESBL evolution and quantifying mutational contributions to ESBL variants. Authors investigate the evolution E. coli TEM-1 β-lactamase into ESBLs with a complete library of 55,296 TEM-1 β-lactamase variants, showing that adaptation to a non-native antibiotic is driven by higher-order epistasis, making resistance evolution far less predictable than to the native substrate.