In the absence of migration, species persistence depends on adaption to a changing environment, but whether and how adaptation to global change is altered by community diversity is not understood. Community diversity may prevent, enhance or alter how species adapt to changing conditions by influencing population sizes, genetic diversity and/or the fitness landscape experienced by focal species. We tested the impact of community diversity on adaptation by performing a reciprocal transplant experiment on grasses that evolved for 14 years under ambient and elevated CO2, in communities of low or high species richness. Using biomass as a fitness proxy, we find evidence for local adaptation to elevated CO2, but only for plants assayed in a community of similar diversity to the one experienced during the period of selection. Our results indicate that the biological community shapes the very nature of the fitness landscape within which species evolve in response to elevated CO2.