Spatial variation in biodiversity is one of the key pieces of information for the delimitation and prioritisation of protected areas. This information is especially important when the protected area includes different climatic and habitat conditions and communities, such as those along elevational gradients. Here we test whether the megadiverse communities of spiders along an elevational gradient change according to two diversity models - a monotonic decrease or a hump-shaped pattern in species richness. We also measure compositional variation along and within elevations, and test the role of the preference of microhabitat (vegetation strata) and the functional (guild) structure of species in the changes. We sampled multiple spider communities using standardised and optimised sampling in three forest types, each at a different elevation along a climatic gradient. The elevational transects were at increasing horizontal distances (between 0.1 and 175 km) in the Udzungwa Mountains, Eastern Arc Mountains, Tanzania. The number of species was similar between plots and forest types, and therefore the pattern did not match either diversity model. However, species composition changed significantly with a gradual change along elevations. Although the number of species per microhabitat and guild also remained similar across elevations, the number of individuals varied, e.g. at higher elevations low canopy vegetation was inhabited by more spiders, and the spiders belonging to guilds that typically use this microhabitat were more abundant. Our findings reflex the complex effects of habitat-microhabitat interactions on spider communities at the individual, species and guild levels. If we aim to understand and conserve some of the most diverse communities in the world, researchers and managers may need to place more attention to small scale and microhabitat characteristics upon which communities depend.Peer reviewe