Summary Dissecting drivers of plant defence investment remains central for understanding the assemblage of communities across different habitats. There is increasing evidence that direct defence strategies against herbivores, including secondary metabolites production, differ along ecological gradients in response to variation in biotic and abiotic conditions. In contrast, intraspecific variation in indirect defences remains unexplored. Here, we investigated variation in herbivory rate, resistance to herbivores and indirect defences in ant‐attracting Vicia species along the elevation gradient of the Alps. Specifically, we compared volatile organic compounds (VOCs) and ant attraction in high‐ and low‐elevation ecotypes. Consistent with adaptation to the lower herbivory conditions that we detected at higher elevations in the field, high‐elevation plants were visited by fewer ants and were more susceptible to herbivore attack. In parallel, constitutive volatile organic compound production and subsequent ant attraction were lower in the high‐elevation ecotypes. We observed an elevation‐driven trade‐off between constitutive and inducible production of VOCs and ant attraction along the environmental cline. At higher elevations, inducible defences increased, while constitutive defence decreased, suggesting that the high‐elevation ecotypes compensate for lower indirect constitutive defences only after herbivore attack. Synthesis. Overall, direct and indirect defences of plants vary along elevation gradients. Our findings show that plant allocation to defences are subject to trade‐offs depending on local conditions, and point to a feedback mechanism linking local herbivore pressure, predator abundance and the defence investment of plants.