Evolution depends on mutations. For an individual genotype, the rate at which mutations arise is known to increase with various stressors (stress-induced mutagenesis—SIM) and decrease at high final population density (density-associated mutation-rate plasticity—DAMP). We hypothesised that these two forms of mutation-rate plasticity would have opposing effects across a nutrient gradient. Here we test this hypothesis, culturing Escherichia coli in increasingly rich media. We distinguish an increase in mutation rate with added nutrients through SIM (dependent on error-prone polymerases Pol IV and Pol V) and an opposing effect of DAMP (dependent on MutT, which removes oxidised G nucleotides). The combination of DAMP and SIM results in a mutation rate minimum at intermediate nutrient levels (which can support 7 × 108 cells ml−1). These findings demonstrate a strikingly close and nuanced relationship of ecological factors—stress and population density—with mutation, the fuel of all evolution.