Dan'gun appears to have been worshipped only locally in the Pyongyang area until the thirteenth century, when intellectuals attempted to bolster the legitimacy of the Korean state, then imperiled by Mongol invasion and domination, by establishing him as the ancestor of all Korean polities. By the twentieth century he had become accepted as the mythical founder of the Korean nation and plays an important role in the ideologies of both North and South Korea.