Climate change will have dangerous impacts on future generations. Accordingly, people in the present have an obligation to make sacrifices for the benefit of future others. However, research on temporal and social discounting shows that people are short-sighted and selfish—they prefer immediate over delayed benefits, and they prefer benefits for themselves over others. Discounting over long-term time horizons is known as intergenerational discounting, and is a major obstacle to climate action. Here, we examine whether persuasive messages that activate the legacy motive—the desire to build a positive legacy—can increase the willingness of current actors to make sacrifices for future generations. Using a climate change public goods game, we find that when the benefits of cooperation accrue to decision makers in the present, high levels of cooperation are sustained, whereas when the benefits accrue to future generations, intergenerational discounting makes cooperation elusive. Crucially, when the legacy motive is activated—by promoting death awareness, feelings of power asymmetry, and intergenerational reciprocity—intergenerational discounting is attenuated, and cooperation is restored. Our results suggest climate action can be fostered by framing climate change as an intergenerational dilemma, and by crafting persuasive messages that activate people’s drive to leave a positive legacy.