The origins of both religion and complex societies represent evolutionary puzzles [1][2][3][4][5][6][7][8] . The moralizing gods hypothesis offers a solution to both puzzles by proposing that belief in morally concerned supernatural agents culturally evolved to facilitate cooperation among strangers in large-scale societies [9][10][11][12][13] . While previous research has suggested an association between presence of moralizing gods and social complexity 3,6,7,[9][10][11][12][13][14][15][16][17][18] , the relationship between the two is disputed 9,10,13,19,20,23,24 , and attempts to establish causality have been hampered by limitations in the availability of detailed global longitudinal data. To overcome these limitations, we systematically coded records for 414 societies spanning the last 10,000 years from 30 regions around the world, based on 51 measures of social complexity and four measures of supernatural enforcement of morality. Our analyses confirm the association between moralizing gods and social complexity but reveal that moralizing gods follow, rather than precede, large increases in social complexity. Contrary to previous predictions 9,12,16,18 , powerful moralizing "big gods", and prosocial supernatural punishment more generally, tend to appear only after the emergence of "megasocieties" with populations of greater than around a million. Although moralizing gods are not a prerequisite for the evolution of social complexity, they may help to sustain and expand complex multiethnic empires after they have become established. In contrast, rituals facilitating the standardization of religious traditions across large populations 25,26 generally precede the appearance of moralizing gods. This suggests that ritual practices were more important than the particular content of religious belief to the initial rise of social complexity.Supernatural agents that punish direct affronts to themselves (e.g. failure to perform sacrifices or observe taboos) are commonly represented in global history, but rarely are such deities believed to punish moral violations in interactions between humans 2 . Recent