1. Trait-based approaches predict ecosystem functioning under environmental change by relating traits predicting changes in species densities (response traits) to traits driving ecosystem functioning (effect traits). Stressors can however affect ecosystem functioning not only by altering species densities, but also by directly changing species effect traits. 2. We first identified the response traits predicting the cell density of 18 marine benthic diatom strains along gradients of two chemical stressors (a pesticide and a metal, atrazine and copper). We then tested if response traits could predict stressor-induced changes in ecosystem functioning, i.e. changes in the effect traits driving the diatoms’ potential contribution to primary production, sediment stabilization and energy content in intertidal systems. Finally, we examined if changes in density and changes in ecosystem functioning were correlated, to assess whether species capable of growing under stressful conditions could maintain their contribution to ecosystem functioning. 3. The relationship between response traits and stressor-induced changes in density and ecosystem functioning was different depending on stressor type: a set of intercorrelated morphological traits predicted changes in both density and ecosystem functioning under metal stress, with large cells being more stress-resistant. Changes in density and changes in ecosystem functioning were positively related: diatoms whose density was least affected by the metal were also able to sustain functioning under metal exposure. 4. In contrast, the capacity for mixotrophic growth predicted changes in density, but not changes in ecosystem functioning under pesticide stress. Pesticide effects on density and on ecosystem functioning were negatively related for energy content and sediment stabilization, indicating a limited capacity of pesticide-tolerant diatoms to maintain their contribution to ecosystem functioning. Synthesis. Ecosystem functioning under stress can depend on whether response traits driving changes in density also predict direct stress effects on the species’ contribution to ecosystem functioning. Based on our results, we expect a disproportionate loss of functioning when traits driving species densities do not allow to maintain ecosystem functioning under stress.