Background The microbiome in plant-soil systems has a significant influence in promoting plant growth. The extent of selectivity that the plant exerts on the microbiome in the continuum of internal plant tissues is not well understood. This study analysed the root microbiome of a legume, Melilotus officinalis (L.) Pall., sweet clover, and focused on dynamic shifts in the microbial community structure through the niches of bulk soil, rhizosphere, periderm, phloem and xylem, and further examined the effects of environmental factors, root exudates and root cell wall development on the microbiome assemblages in different root compartments.ResultsYoung and mature plants were sampled at 24 field sites and the microbial communities in different niches from bulk soil and rhizosphere through to root compartments were analysed by 16S rRNA gene sequencing. The microbiome composition changed from periderm to phloem to a greater extent than across other boundaries (0.95 vs 0.71 based Bray–Curtis distance). Variation in microbiome composition was associated with geographic distance and soil properties for the bulk soil, rhizosphere and periderm niches. The composition of root exudate compounds were correlated with the rhizosphere microbiome assemblages in mature and young plants. The endophyte communities that occupied the phloem and xylem were most conserved and were independent of growing environments and root exudation. Symbiotic rhizobia able to nodulate M. officinalis were prominent colonisers of the periderm (~15%) and xylem (~6.2%), but were only a minor component in other soil-related niches (0.1%-2.5%). In xylem tissues, endophyte diversity was correlated with the total cell wall and lignin content across the sampled sites (r=0.29-0.62). Conclusions Our results demonstrate that selection of microbiome constituents occurs at different boundaries through bulk soil, rhizosphere, periderm, phloem and xylem, and is especially strong across the periderm boundary. The conserved endophyte community in the innermost tissues (phloem and xylem) was identified, and will be advantageous to the development of specific beneficial microbial inoculants.