Previous studies have shown that the response of bacterial communities to disturbances depends on their environmental history. Historically fluctuating habitats host communities that respond better to disturbance than communities of historically stable habitats. However, the exact ecological mechanism that drives this dependency remains unknown. Here, we experimentally demonstrate that modifications of niche optima and niche breadths of the community members are driving this dependency of bacterial responses to past environmental conditions. First, we develop a novel, simple method to calculate the niche optima and breadths of bacterial taxa regarding single environmental gradients. Then, we test this method on sediment bacterial communities of three habitats, one historically stable and less loaded and two historically more variable and more loaded habitats in terms of historical chlorophyll-α water concentration, that we subject to hypoxia via organic matter addition ex situ. We find that communities containing bacterial taxa differently adapted to hypoxia show different structural and functional responses, depending on the sediment's environmental history. Specifically, in the historically less fluctuating and loaded sediments where we find more taxa poorly adapted to hypoxic conditions, communities change a lot over time and organic matter is not degraded efficiently. The opposite is true for the historically more fluctuating and loaded sediments where we find more taxa well adapted to hypoxia. Based on the community responses observed here, we also propose an alternative calculation of community resistance that takes into account how rapidly the communities respond to disturbances and not just the initial and final states of the community.