While abiotic variation is undoubtedly important in shaping the composition of ecological communities, the extent to which environment predicts composition varies between communities and habitats. This raises the question of which features lead to robustness in the face of environmental change. We identify spatial structure as a major factor in dampening the effects of abiotic variation. Individual-based models predict that spatial structure leads to compositional convergence between environments that impose divergent selection pressures. We then test these predictions using microbial communities cultured on divergent carbon sources and which experience different degrees of spatial structure provided by glass beads. Again, more spatial structure results in increased community convergence across abiotic environments. Our work suggest that spatial structure can mitigate against the ecological consequences of environmental heterogeneity.