The ability to accurately assess others’ intents, beliefs, and emotions—called Theory of Mind (ToM)—is important for social cooperation. We study the role of ToM ability in fostering cooperation in the Simultaneous and Sequential Prisoners Dilemma (PD) games. We theoretically examine multiple models of social preferences and find that the relationship between ToM ability and cooperation is complex and sensitive to subtle changes in context such as population characteristics, beliefs, and the sequencing of moves. To resolve the theoretical uncertainty, we conduct a series of experiments to test how ToM influences cooperation in one-shot PD interactions. We find that differences in ToM ability are not correlated with cooperation in Simultaneous PD, but that higher ToM ability is correlated with increased cooperation in Sequential PD. Moreover, ToM ability affects cooperation via accuracy in beliefs about others’ cooperativeness rather than an association with fixed preference traits. Finally, we show that when direct inference of emotional states is possible, individuals with high ToM ability are better at recognizing the potential cooperativeness of others, thereby enabling a payoff advantage to having high ToM. Overall, our paper demonstrates how individual-level differences in ToM help to explain differences in cooperativeness.