Abstract Aim To examine the relationship between ecoregions, as a proxy for regional climate and habitat type, and mammalian community structure, defined by species composition and richness (e.g. taxonomic structure) and ecological diversity (e.g. ecological structure) of non-volant species. Location Madagascar. Methods Faunal lists of non-volant mammal species occurring in 35 communities from five World Wildlife Fund ecoregions were collected from published and unpublished sources. Species were assigned to ecological groups defined by trophic status, locomotor habits, activity cycle and body mass. We used Mantel tests, cluster analysis and principal coordinates analysis to evaluate geographic patterning in taxonomic composition and species richness. We used stepwise multiple discriminant analysis to characterize patterns in the ecological diversity of the mammalian communities from each ecoregion. Communities from transitional habitats (e.g. representing more than one ecoregion) were used to test the predictive power of the analyses. Results Non-volant mammal communities divided into clusters that correspond to ecoregions. There was a strong distance effect in the taxonomic structure of communities across the island and within both humid and dry forest communities, but this effect was weak within humid forest communities. Mammalian species richness was significantly lower in dry forest than in humid forest communities. The ecological structure of communities was also correlated with ecoregions. Changes in the relative percentages of omnivory, arboreal quadrupedalism, terrestrial/arboreal quadrupedalism and two body mass classes accounted for 98.1% of the variation in ecological structure. Transitional communities were projected in intermediate positions by the discriminant model. Main conclusions Our analysis demonstrates that the broad-scale habitat and climate variables captured by the ecoregion model have shaped the assembly of non-volant mammal communities in Madagascar over evolutionary time. The spatial pattern is consistent with ecological sorting of species ranges along environmental gradients. Historical processes, such as recent extinction and migration, may have also affected the structure of mammal communities, although these factors have played a secondary role.