Yersinia pestis is transmitted from fleas to rodents when the bacterium develops an extensive biofilm in the foregut of a flea, starving it into a feeding frenzy, or, alternatively, during a brief period directly after feeding on a bacteremic host. These two transmission modes are in a trade-off regulated by the amount of biofilm produced by the bacterium. Here by investigating 446 global isolated Y. pestis genomes, including 78 newly sequenced isolates sampled over 40 years from a plague focus in China, we provide evidence for strong selection pressures on the RNA polymerase ω-subunit encoding gene rpoZ. We demonstrate that rpoZ variants have an increased rate of biofilm production in vitro, and that they evolve in the ecosystem during colder and drier periods. Our results support the notion that the bacterium is constantly adapting-through extended phenotype changes in the fleas-in response to climate-driven changes in the niche.