The genetic diversity found in natural populations is the result of the evolutionary forces in response to historical and contemporary factors. The environmental characteristics and geological history of Mexico promoted the evolution and diversification of plant species, including wild relatives of crops such as the wild pumpkins (Cucurbita). Wild pumpkin species are found in a variety of habitats, evidencing their capability to adapt to different environments. Despite the potential value of wild Cucurbita as a genetic reservoir for crops, there is a lack of studies on their genetic diversity. Cucurbita radicans is an endangered species threatened by habitat destruction leading to low densities in small and isolated populations. Here, we analyze Genotype by Sequencing genomic data of the wild pumpkin C. radicans to evaluate the influence of factors like isolation, demographic history, and the environment shaping the amount and distribution of its genetic variation. We analyzed 91 individuals from 14 localities along its reported distribution. We obtained 5,107 SNPs and found medium-high levels of genetic diversity and genetic structure distributed in four main geographic areas with different environmental conditions. Moreover, we found signals of demographic growth related to historical climatic shifts. Outlier loci analysis showed significant association with the environment, principally with precipitation variables. Also, the outlier loci displayed differential changes in their frequencies in response to future global climate change scenarios. Using the results of genetic structure, outlier loci and multivariate analyses of the environmental conditions, we propose priority localities for conservation that encompass most of the genetic diversity of C. radicans.