Organisms often face a higher risk of local extinction in fragmented than in continuous habitat. However, whether populations are affected by reduced size and connectivity of the habitat or by changes in habitat quality in fragmented landscapes remains poorly investigated. We studied the regional distribution and microhabitat selection of the lacertid lizard Psammodromus algirus in a fragmented landscape where the existence of deciduous and evergreen woodlands brought about variation in habitat quality. Lizards never occupied any fragment smaller than 0.5 ha. However, above that limit fragment size no longer predicted lizard occurrence, which was explained by woodland type instead, with lizards being more frequently found in deciduous than in evergreen woodlands. Lizards selected microhabitats that had structural features favouring thermoregulation, foraging and predator avoidance, and we identified better conditions for thermoregulation and food acquisition in deciduous than in evergreen woodlands. Our results support the idea that variation in habitat quality can sometimes override the effect of habitat fragmentation on animal populations. We consider the implications of our study for the conservation of Mediterranean lizards, discussing our results in a broader context framed by previous studies conducted in nearby areas.