In the present study the population genetic structure of the terrestrial snail Pomatias elegans was related to habitat structure on a microspatial scale. The genetic variability of 1607 individuals from 51 sampling sites in five different populations in Provence, France, was studied with an allozyme marker using population genetic methods, Mantel tests and spatial autocorrelation techniques were applied to different connectivity networks accounting for the structural features of the landscape. It is suggested that the population structure is, to a large extent, a function of the habitat quality, quantified as population density, and of the spatial arrangement of the habitat in the landscape and not of the geographical distance per se. In fragmented habitats, random genetic drift was the prevailing force for sampling sites separated by a few hundred meters. © 2002 The Linnean Society of London, Biological Journal of the Linnean Society, 2002, 76, 565–575.