Disentangling the drivers of diversity gradients can be challenging. The Measurement of Biodiversity (MoB) framework decomposes scale-dependent changes in species diversity into three components of community structure: species abundance distribution (SAD), total community abundance, and within-species spatial aggregation. Here we extend MoB from categorical treatment comparisons to quantify variation along continuous geographic or environmental gradients. Our approach requires sites along a gradient, each consisting of georeferenced plots of abundance-based species composition data. We demonstrate our method using a case study of ants sampled along an elevational gradient of 28 sites in a mixed deciduous forest of the Great Smoky Mountains National Park, USA. MoB analysis revealed that decreases in ant species richness along the elevational gradient were associated with decreasing evenness and total number of species, which counteracted the modest increase in richness associated with decreasing spatial aggregation along the gradient. Total community abundance had a negligible effect on richness at all but the finest spatial grains, SAD effects increased in importance with sampling effort, and the aggregation effect had the strongest effect at coarser spatial grains. These results do not support the more-individuals hypothesis, but they are consistent with a hypothesis of stronger environmental filtering at coarser spatial grains. Our extension of MoB has the potential to elucidate how components of community structure contribute to changes in diversity along environmental gradients and should be useful for a variety of assemblage-level data collected along gradients.