Spatially varying selection triggers differential adaptation of local populations. Here, we mined the determinants of local adaptation at the genomewide scale in the two closest maize wild relatives, the teosintes Zea mays ssp parviglumis and ssp. mexicana. We sequenced 120 individuals from six populations: two lowland, two intermediate and two highland populations sampled along two altitudinal gradients. We detected 8 479 581 single nucleotide polymorphisms (SNPs) covered in the six populations with an average sequencing depth per site per population ranging from 17.0× to 32.2×. Population diversity varied from 0.10 to 0.15, and linkage disequilibrium decayed very rapidly. We combined two differentiation-based methods, and correlation of allele frequencies with environmental variables to detect outlier SNPs. Outlier SNPs displayed significant clustering. From clusters, we identified 47 candidate regions. We further modified a haplotype-based method to incorporate genotype uncertainties in haplotype calling, and applied it to candidate regions. We retrieved evidence for selection at the haplotype level in 53% of our candidate regions, and in 70% of the cases the same haplotype was selected in the two lowland or the two highland populations. We recovered a candidate region located within a previously characterized inversion on chromosome 1. We found evidence of a soft sweep at a locus involved in leaf macrohair variation. Finally, our results revealed frequent colocalization between our candidate regions and loci involved in the variation of traits associated with plant-soil interactions such as root morphology, aluminium and low phosphorus tolerance. Soil therefore appears to be a major driver of local adaptation in teosintes.