Understanding the role of host genome in modulating microbiota variation is a need to shed light into the holobiont theory and overcome the current limits on the description of host-microbiota interactions at the genomic and molecular levels. However, the host genetic architecture structuring microbiota is only partly described in plants. In addition, most association genetic studies on microbiota are often carried out outside the native habitats where the host evolve and the identification of signatures of local adaptation on the candidate genes has been overlooked. To fill these gaps and dissect the genetic architecture driving adaptive plant-microbiota interactions, we adopted a Genome-Environmental-Association (GEA) analysis on 141 whole-genome sequenced natural populations of Arabidopsis thaliana characterized in situ for their leaf and root bacterial communities and a large range of environmental descriptors (i.e. climate, soil and plant communities). Across 194 microbiota traits, a much higher fraction of among-population variance was explained by the host genetics than by ecology, with the plant neighborhood as the main ecological driver of microbiota variation. Importantly, the relative importance of host genetics and ecology expressed a phylogenetic signal at the family and genus level. In addition, the polygenic architecture of adaptation to bacterial communities was highly flexible between plant compartments and seasons. Relatedly, signatures of local adaptation were stronger on QTLs of the root microbiota in spring. Finally, we provide evidence that plant immunity, in particular the FLS2 gene, is a major source of adaptive genetic variation structuring bacterial assemblages in A. thaliana.