The adaptation of populations to changing conditions may be affected by interactions between individuals. For example, cooperative interactions may allow populations to maintain high densities, and thus keep track of moving environmental optima. At the same time, changes in population density alter the marginal benefits of cooperative investments, creating a feedback loop between population dynamics and the evolution of cooperation. Here we model how the evolution of cooperation is affected by, and in turn affects, adaptation to a changing environment. We hypothesize that changes in the environment lower population size and thus promote the evolution of cooperation, and that this in turn helps the population keep up with the moving optimum. However, we find that the evolution of cooperation can have qualitatively different effects, depending on which fitness component is reduced by the costs of cooperation. If the costs decrease fecundity, cooperation indeed speeds adaptation by increasing population density; if, in contrast, the costs decrease viability, cooperation may in fact slow adaptation by lowering the effective population size, leading to evolutionary suicide. Thus, we show that cooperation can either promote or—counter-intuitively—hinder adaptation to a changing environment.