Understanding processes that determine biodiversity is a fundamental challenge in ecology. At the landscape scale, physical alteration of ecosystems by organisms, called ecosystem engineering, enhances biodiversity worldwide by increasing heterogeneity in resource conditions and enhancing species coexistence across engineered and non-engineered habitats. Engineering–diversity relationships can vary along environmental gradients due to changes in the amount of physical structuring created by ecosystem engineering, but it is unclear how this variation is influenced by the responsiveness of non-structural abiotic properties to engineering. Here we show that environmental gradients determine the capacity for engineering to alter resource availability and species diversity, independent of the magnitude of structural change produced by engineering. We created an experimental rainfall gradient in an arid grassland where rodents restructure soils by constructing large, long-lasting burrows. We found that greater rainfall increased water availability and productivity in both burrow and inter-burrow habitats, causing a decline in local (alpha) plant diversity within both of these habitats. However, increased rainfall also resulted in greater differences in soil resources between burrow and inter-burrow habitats, which increased species turnover (beta diversity) across habitats and stabilized landscape-level (gamma) diversity. These responses occurred regardless of rodent presence and without changes in the extent of physical alteration of soils by rodents. Our results suggest that environmental gradients can influence the effects of ecosystem engineering in maintaining biodiversity via resource heterogeneity and species turnover. In an era of rapid environmental change, accounting for this interaction may be critical to conservation and management.