Adaptation to different environments in geographically separated populations is key for allopatric speciation. Most research has focused on the effects of geographical isolation and abiotic factors, but disjunct populations frequently co-occur with different pools of species, favouring divergent adaptation and speciation. We show the importance of plant neighbourhood, compared to geographic and environmental factors, in the allopatric speciation of two closely related plants, Carex elata and Carex reuteriana. Both species share similar ecological requirements and inhabit river shores at medium to low altitudes across the Iberian Peninsula. We employed a multidisciplinary approach integrating abiotic, biotic and geographical factors, and genomic data (genotyping-by-sequencing) to infer the relative role of different evolutionary drivers. Abiotic factors were assessed based on 38 bioclimatic variables, biotic factors using the community of co-occurring plant species (1536 vegetation inventories), and geographical factors with a distance matrix based on geographic coordinates. Using regularised generalised linear models, we identified the key variables explaining distribution patterns. We also examined the relationships between inter-population genetic distances, and biotic, abiotic and geographic factors to understand the drivers of lineage splitting, revealing varying degrees of influence. Plant neighbourhood emerged as a stronger predictor of allopatric distributions than abiotic or geographic factors, with the largest effect observed in Carex elata, which exhibited the greatest population differentiation. These findings suggest that the biotic and microenvironmental factors influencing divergent plant neighbourhoods have significantly contributed to the differentiation of these taxa, providing new insights into the evolutionary processes shaping the origin and distribution of species.