Climate change affects ecosystem functioning directly through impacts on plant physiology, resulting in changes of global productivity. However, climate change has also an indirect impact on ecosystems, through changes in the composition and diversity of plant communities. The relative importance of these direct and indirect effects has not been evaluated within a same generic approach yet. Here we took advantage of a novel approach for disentangling these two effects in European temperate forests across a large climatic gradient, through a large simulation-based study using a forest succession model. We first showed that if productivity positively correlates with realized tree species richness under a changed climate, indirect effects appear pivotal to understand the magnitude of climate change impacts on forest productivity. We further detailed how warmer and drier conditions may affect the diversity-productivity relationships (DPRs) of temperate forests in the long term, mostly through effects on species recruitment, ultimately enhancing or preventing complementarity in resource use. Furthermore, losing key species reduced the strength of DPRs more severely in environments that are becoming climatically harsher. By disentangling direct and indirect effects of climate change on ecosystem functioning, these findings explain why high-diversity forests are expected to be more resilient to climate change.