Human-induced transformations of ecosystems usually result in fragmented populations subject to increased extinction risk. Fragmentation is also often associated with novel environmental heterogeneity, which in combination with restricted gene flow may increase the opportunity for local adaptation. To manage at-risk populations in these landscapes, it is important to understand how gene flow is changing, and how populations respond to habitat loss. We conducted a landscape genomics analysis using Restriction-site Associated DNA sequencing to investigate the evolutionary response of the critically endangered Dahl's Toad-headed turtle (Mesoclemmys dahli) to severe habitat modification. The species has lost almost all of its natural habitat in the southwestern part of its range and about 70% in the northeast. Based on least cost path analysis across different resistance surfaces for 3,211 SNPs, we found that the landscape matrix is restricting gene flow, causing the fragmentation of the species into at least six populations. Genome scans and allele-environment association analyses indicate that the population fragments in the deforested grasslands of the southwest are adaptively different from those in the more forested northeast. Populations in areas with no forest had low levels of adaptive genetic diversity and the fixation of ancestrally-polymorphic SNPs, consistent with directional selection in this novel environment. Our results suggest that this forest-stream specialist is adapting to pond-grassland conditions, but it is also suffering from negative consequences of habitat loss, including genetic erosion, isolation, small effective population sizes, and inbreeding. We recommend gene flow restoration via genetic rescue to counteract these threats, and provide guidance for this strategy.