Gene regulatory networks allow organisms to generate coordinated responses to environmental challenges. In bacteria, regulatory networks are re-wired and re-purposed during evolution, though the relationship between selection pressures and evolutionary change is poorly understood. In this study, we discover that the early evolutionary response of Escherichia coli to the antibiotic trimethoprim involves derepression of PhoPQ signaling, an Mg2+-sensitive two-component system, by inactivation of the MgrB feedback-regulatory protein. We report that derepression of PhoPQ confers trimethoprim-tolerance to E. coli by hitherto unrecognized transcriptional upregulation of dihydrofolate reductase (DHFR), target of trimethoprim. As a result, mutations in mgrB precede and facilitate the evolution of drug resistance. Using laboratory evolution, genome sequencing, and mutation re-construction, we show that populations of E. coli challenged with trimethoprim are faced with the evolutionary ‘choice’ of transitioning from tolerant to resistant by mutations in DHFR, or compensating for the fitness costs of PhoPQ derepression by inactivating the RpoS sigma factor, itself a PhoPQ-target. Outcomes at this evolutionary branch-point are determined by the strength of antibiotic selection, such that high pressures favor resistance, while low pressures favor cost compensation. Our results relate evolutionary changes in bacterial gene regulatory networks to strength of selection and provide mechanistic evidence to substantiate this link.