It is generally accepted that the spatial distribution of neutral genetic diversity within a species’ native range mostly depends on effective population size, demographic history, and geographic position. However, it is unclear how genetic diversity at adaptive loci correlates with geographic peripherality or with habitat suitability within the ecological niche. Using exome-wide genomic data and distribution maps of the Alpine range, we first tested whether geographic peripherality correlates with four measures of population genetic diversity at >17,000 SNP loci in 24 Alpine populations (480 individuals) of Swiss stone pine (Pinus cembra) from Switzerland. To distinguish between neutral and adaptive SNP sets, we used four approaches (two gene diversity estimates, FST outlier test, and environmental association analysis) that search for signatures of selection. Second, we established ecological niche models for P. cembra in the study range and investigated how habitat suitability correlates with genetic diversity at neutral and adaptive loci. All estimates of neutral genetic diversity decreased with geographic peripherality, but were uncorrelated with habitat suitability. However, heterozygosity (He) at adaptive loci based on Tajima’s D declined significantly with increasingly suitable conditions. No other diversity estimates at adaptive loci were correlated with habitat suitability. Our findings suggest that populations at the edge of a species’ geographic distribution harbour limited neutral genetic diversity due to demographic properties. Moreover, we argue that populations from suitable habitats went through strong selection processes, are thus well adapted to local conditions, and therefore exhibit reduced genetic diversity at adaptive loci compared to populations at niche margins.