Abstract. The relative effects of two components of mountain environmental heterogeneity, altitude (1500, 1700 and 2000 m a.s.l.) and habitat (pastures, coniferous forests, wet meadows, scrub and anthropogenic woods) on the diversity of dung beetles in an Italian alpine valley were determined. The additive gamma diversity analysis indicated that differences among habitats (ßH) were always smaller than those among altitudes (ßA), irrespective of the measures used; it also showed that the contribution of ßA to -diversity was higher than expected by chance for all the measures of species diversity used, whereas the contribution of ßH was significantly higher in the case of one measure only. Generalized linear models confirmed that altitude was the most important factor associated with local diversity, with all the diversity parameters considered progressively and significantly increasing with increasing altitude. Indicator species analyses revealed that dung beetle altitudinal and habitat diversity patterns depended on local choice of species, with preferences for altitudinal levels being more numerous and apparent than those for habitats. Despite the minor effect of habitat differences, comparing a three-habitat with a single-habitat scenario it was possible to demonstrate that greater habitat heterogeneity is associated with a significantly greater diversity of dung beetles. This study suggests that preservation of local environmental heterogeneity by means of traditional pastoral activities should be encouraged as a means of conserving the diversity of dung beetle species in the Alps.