Healthy plants host diverse but taxonomically structured communities of microorganisms, the plant microbiota, that colonize every accessible plant tissue. Plant-associated microbiomes confer fitness advantages to the plant host, including growth promotion, nutrient uptake, stress tolerance and resistance to pathogens. In this Review, we explore how plant microbiome research has unravelled the complex network of genetic, biochemical, physical and metabolic interactions among the plant, the associated microbial communities and the environment. We also discuss how those interactions shape the assembly of plant-associated microbiomes and modulate their beneficial traits, such as nutrient acquisition and plant health, in addition to highlighting knowledge gaps and future directions.