Legumes have an intrinsic capacity to accommodate both symbiotic and endophytic bacteria within root nodules. For the symbionts, a complex genetic mechanism that allows mutual recognition and plant infection has emerged from genetic studies under axenic conditions. In contrast, little is known about the mechanisms controlling the endophytic infection. Here we investigate the contribution of both the host and the symbiotic microbe to endophyte infection and development of mixed colonised nodules in Lotus japonicus. We found that infection threads initiated by Mesorhizobium loti, the natural symbiont of Lotus, can selectively guide endophytic bacteria towards nodule primordia, where competent strains multiply and colonise the nodule together with the nitrogen-fixing symbiotic partner. Further co-inoculation studies with the competent coloniser, Rhizobium mesosinicum strain KAW12, show that endophytic nodule infection depends on functional and efficient M. loti-driven Nod factor signalling. KAW12 exopolysaccharide (EPS) enabled endophyte nodule infection whilst compatible M. loti EPS restricted it. Analysis of plant mutants that control different stages of the symbiotic infection showed that both symbiont and endophyte accommodation within nodules is under host genetic control. This demonstrates that when legume plants are exposed to complex communities they selectively regulate access and accommodation of bacteria occupying this specialized environmental niche, the root nodule.