Biodiversity may increase ecosystem resilience. However, we have limited understanding if this holds true for ecosystems that respond to gradual environmental change with abrupt shifts to an alternative state. We used a mathematical model of anoxic-oxic regime shifts and explored how trait diversity in three groups of bacteria influences resilience. We found that trait diversity did not always increase resilience: greater diversity in two of the groups increased but in one group decreased resilience of their preferred ecosystem state. We also found that simultaneous trait diversity in multiple groups often led to reduced or erased diversity effects. Overall, our results suggest that higher diversity can increase resilience but can also promote collapse when diversity occurs in a functional group that negatively influences the state it occurs in. We propose this mechanism as a potential management approach to facilitate the recovery of a desired ecosystem state.