Understanding how environmental factors shape patterns of genetic and phenotypic variations in a species is necessary for conservation and plant breeding. However, these factors have not yet been completely understood in tuberous orchid species used to make 'Salep', an important ingredient in traditional medicine and beverages in middle eastern countries and India. In many areas, increasing demand has pushed species to the brink of extinction. In this study, 198 genotypes from 18 populations of the endangered species Orchis mascula L. spanning a large-scale climatic gradient in northern Iran were used to investigate patterns of genetic diversity and plant functional traits. Populations were sampled from three land cover types (woodland, shrubland, and pastureland/grassland). Plant height, stem length, number of flowers, bulb fresh and dry weight, glucomannan, and starch concentrations showed high variation among populations and were significantly related to land cover type. In general, genetic diversity was high, particularly in those from eastern Hyrcanian; additionally, populations showed a high level of genetic differentiation (G'st = 0.35) with low gene flow (Nm = 0.46). The majority of genetic differentiation occurred within populations (49%) and land cover types (20%). The population structural analysis using the AFLP marker data in K = 4 showed a high geographical affinity for 198 O. mascula genotypes, with some genotypes having mixed ancestry. Temperature and precipitation were found to shape genetic and phenotypic variation profoundly. Significant isolation by the environment was observed, confirming the strong effect of environmental variables on phenotypic and genetic variation. Marker-trait association studies based on MLM1 and MLM2 models revealed significant associations of P-TGG + M-CTT-33 and E-AGG + M-CGT-22 markers with plant height and glucomannan content. Overall, a combination of large-scale climatic variables and land cover types significantly shaped genetic diversity and functional trait variation in O. mascula populations.