A 2-year prospective intervention on the prescription of trimethoprim reduced the use by 85% in a health care region with 178,000 inhabitants. Here, we performed before-and-after analyses of the within-population distribution of trimethoprim resistance in Escherichia coli. Phylogenetic and population genetic methods were applied to multilocus sequence typing data of 548 consecutively collected E. coli isolates from clinical urinary specimens. Results were analyzed in relation to antibiotic susceptibility and the presence and genomic location of different trimethoprim resistance gene classes. A total of 163 E. coli sequence types (STs) were identified, of which 68 were previously undescribed. The isolates fell into one of three distinct genetic clusters designated BAPS 1 (E. coli phylogroup B2), BAPS 2 (phylogroup A and B1), and BAPS 3 (phylogroup D), each with a similar frequency before and after the intervention. BAPS 2 and BAPS 3 were positively and BAPS 1 was negatively associated with trimethoprim resistance (odds ratios of 1.97, 3.17, and 0.26, respectively). In before-and-after analyses, trimethoprim resistance frequency increased in BAPS 1 and decreased in BAPS 2. Resistance to antibiotics other than trimethoprim increased in BAPS 2. Analysis of the genomic location of different trimethoprim resistance genes in isolates of ST69, ST58, and ST73 identified multiple independent acquisition events in isolates of the same ST. The results show that despite a stable overall resistance frequency in E. coli before and after the intervention, marked within-population changes occurred. A decrease of resistance in one major genetic cluster was masked by a reciprocal increase in another major cluster.