This is the author accepted manuscript. The final version is available from Nature Research via the DOI in this record.The origins of both religion and complex societies represent evolutionary puzzles1–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 societies9–13. While previous research has suggested an association between presence of moralizing gods and social complexity3,6,7,9–18, the relationship between the two is disputed9,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 overc...