Abiotic and biotic factors structure species assembly in ecosystems both horizontally and vertically. However, the way community composition changes along comparable horizontal and vertical distances in complex three-dimensional habitats, and the factors driving these patterns, remain poorly understood. By sampling ant assemblages at comparable vertical and horizontal spatial scales in a tropical rain forest, we compared observed patterns with those predicted according to decreased resource availability in the upper canopy, environmental filtering by microclimate and microhabitat structure, presence of competition in the form of ant mosaics, and structural connectivity. We found although dissimilarity between ant assemblages increased with vertical distance, the dissimilarity was higher horizontally but was independent of distance in this dimension. Moreover, there was not a more rapid increase in horizontal distance-dissimilarity at greater heights in the canopy, as would be predicted if large competitive ant colonies drove these patterns. The pronounced horizontal and vertical structuring of ant assemblages across short distances is likely explained by a combination of microclimate and microhabitat connectivity. Our results demonstrate the importance of considering three-dimensional spatial variation in local assemblages and reveal how highly diverse communities can be supported by complex habitats.