The archetypal PhoQP two-component system from Enterobacteria regulates crucial pathways like magnesium homeostasis in Escherichia coli and virulence factor expression in Salmonella enterica. Previously we had reported that a laboratory strain of E. coli rapidly accumulated loss-of-function mutations in the mgrB gene, a negative feedback regulator of PhoQP, when evolved in the presence of the antibiotic trimethoprim (Patel and Matange, eLife 2021). Hyperactive PhoQP enhanced the expression of dihydrofolate reductase, target of trimethoprim, resulting in antibiotic tolerance. Here we ask, firstly, how important are mutations in mgrB for the evolution of trimethoprim resistance? We report that MgrB loss, though itself only mildly beneficial, facilitates the evolution of resistance by enhancing the fixation probability of trimethoprim-resistant bacteria under selection. Secondly, we investigate why negative feedback may be needed in the PhoQP system. We show that under drug-free conditions MgrB is required to mitigate the fitness costs of pervasive gene dysregulation by hyperactive PhoQP. Using RNA-seq transcriptomics and genetic analyses, we demonstrate that PhoQP-hyperactivation perturbs the balance of RpoS and RpoD regulated transcriptional programs, and spontaneous mutations in rpoS rectify this imbalance. We propose that relative adaptive and maladaptive consequences of deregulation explain the evolution of negative feedback in bacterial gene regulatory networks.