19Disturbance is known to affect ecosystem structure, but predicting its outcomes remains 20 elusive. Similarly, community diversity is believed to relate to ecosystem functions, yet the 21 underlying mechanisms are poorly understood. Here, we tested the effect of disturbance on 22 Importance 40 Microbes drive the Earth's biogeochemical cycles, yet how they respond to perturbations like 41 anthropogenic pollutants is poorly understood. As human impact continues to increase 42 worldwide, foreseeing how disturbances will affect microbial communities and the ecosystem 43 services they provide is key for ecosystem management and conservation efforts. Employing 44 laboratory-scale wastewater treatment bioreactors, this study shows that changes in 45 community diversity accompany variations in the underlying deterministic-stochastic 46 assembly mechanisms. Disturbances could promote stochastic community structuring, which 47 despite harboring higher diversity could lead to variable overall function, possibly explaining 48 why after similar perturbations the process outcome differs. A conceptual framework, termed 49 the 'intermediate stochasticity hypothesis' is proposed to theoretically predict bacterial 50 community shifts in diversity and ecosystem function, given a range of possible disturbance 51 types, in a well-replicated time-series experiment. Our findings are relevant for managing 52 complex microbial systems, which could display similar responses to disturbance, like 53 oceans, soils or the human gut. 54