XP is awarded when you complete certain tasks in the game, such as winning battles, upgrading your buildings, and progressing through the single-player story.