Several recent studies have emphasised that community composition alters species trait evolution. Here, we demonstrate that differences in composition of local herbivore communities lead to divergent trait evolution of the leaf beetle Plagiodera versicolora through plant-mediated indirect interactions. Our field surveys, genetic analyses and community-manipulation experiments show that herbivore community composition determines the degree of herbivore-induced regrowth of willows (Salicaceae), which in turn, promotes the divergent evolution of feeding preference in the leaf beetle from exclusive preference for new leaves to a lack of preference among leaf-age types. Regrowth intensity depends both on the differential response of willows to different herbivore species and the integration of those herbivore species in the community. Because herbivore-induced regrowth involves phenological changes in new leaf production, leaf beetle populations develop divergent feeding preferences according to local regrowth intensity. Therefore, herbivore community composition shapes the selection regime for leaf beetle evolution through trait-mediated indirect interactions.