AbstractHabitat structure is a key determinant of local animal diversity, with attributes of vegetation such as cover or complexity generating key resources for different species. However, habitat–diversity relationships can vary across spatial scales, and among different taxa and ecosystem types. Here we report on a study of habitat structure and its effects on ant communities at two spatial scales in a temperate grassy woodland characterized by heterogenous tree and grassland cover. We examined species richness and the occurrence of ground‐dwelling ant species at (1) microhabitat scales defined by a triplet of sites comprising open ground, adjacent to a log, and under a tree, each separated by a few meters, and (2) at macrohabitat scales defined by sites grouped into broader vegetation types defined by low or high levels of shrub and tree cover and separated by 100s of meters. We identified 117 species of ant from 41 genera, from a total of 155,004 individuals collected. Ant community composition differed significantly among microhabitats and macrohabitats, but mean species richness only differed at the microhabitat scale where it was the highest under trees and lower adjacent to logs and in open ground. Notably, ant species within the genera Iridomyrmex, Monomorium, and Pheidole displayed a spectrum of microhabitat preferences, highlighting the ecological flexibility within these groups. By contrast, all species of Melophorus preferred open habitat and all species of Camponotus preferred habitat under trees. Our study shows that ant communities in grassy woodlands are structured by vegetation cover and habitat “openness” most strongly at “microhabitat” scales, which is likely due to a distinct combination of thermal and foraging attributes that vary across relatively small distances. Our results also suggest that broad classifications of ants into functional types based on vegetation preference may not be applicable at small scales where species within the same genus can display contrasting preferences. Land management that promotes habitat heterogeneity at small spatial scales may promote species coexistence and benefit ant diversity more than management activities focusing on larger spatial scales within the same ecosystem.