Cooperation is essential for human societies, but not all individuals cooperate to the same degree. This variability may relate to individual motives like other-regarding or risk preferences, but also to differences in attention – in other words, how individuals sample and process choice-relevant information. Here we characterize the mechanisms underlying cooperative decisions, by analyzing the choices and gaze behavior of subjects playing one-shot Prisoner’s Dilemma games with varying payoffs. We first confirm that individual cooperation rates respond to variability in payoffs and are primarily driven by other-regarding preferences. However, we find that choices are also impacted by attention to specific payoffs, as well as by individual information sampling strategies measured using eye-tracking. To test for the causal impact of attention over and above subjects’ other-regarding or risk preferences, we systematically manipulate the positions of the payoffs on the screen and find that this significantly affects cooperation rates: It drives subjects’ attention to the other’s payoffs in temporal sequences that favor cooperation. Machine learning classifiers trained on these gaze sequences confirm that such sequences can accurately predict cooperation out-of-sample. Our findings have implications for our understanding of individual differences in cooperation and suggest that attentional interventions can improve cooperative outcomes.