We study how plants employ their immune system to adapt to environmental stress. In stress-free environments, plants invest most of their resources in growth and reproduction. In hostile environments, when attacked by pests and pathogens, plants use a range of short- and long-term strategies to cope with the pressure of biotic stress. These strategies range from rapid immune responses that are activated within seconds, to epigenetic adaptations or recruitment of disease-suppressing microbes that can occur over multiple plant generations.