Understanding what causes the decreasing abundance of species at the margins of their distributions along environmental gradients has drawn considerable interest, especially because of the recent need to predict shifts in species distribution patterns in response to climatic changes. Here, we address the ecological range limit problem by focusing on the sedge, Carex curvula, a dominant plant of high-elevation grasslands in Europe, for which two ecologically differentiated but crosscompatible taxa have been described in the Alps. Our study heuristically combines an extensive phytoecological survey of alpine plant communities to set the niche attributes of each taxon and a population genetic study to assess the multilocus genotypes of 177 individuals sampled in typical and marginal habitats. We found that ecological variation strongly correlates with genetic differentiation. Our data strongly suggest that ecologically marginal populations of each taxon are mainly composed of individuals with genotypes resulting from introgressive hybridization. Conversely, no hybrids were found in typical habitats, even though the two taxa were close enough to crossbreed. Thus, our results indicate that genotype integrity is maintained in optimal habitats, whereas introgressed individuals are favored in marginal habitats. We conclude that gene flow between closely related taxa might be an important, although underestimated, mechanism shaping species distribution along gradients.alpine flora ͉ evolutionary ecology ͉ introgressive hybridization ͉ local adaptation ͉ niche theory