I think it keeps track of both military strenght and civilization one (# of cities, population), but I never figured out exact rating weights.
In my current game for example I'm constantly rushing and swapping first-second place with Yithril, even if we are really different. He has few cities, but a lot of military strenghts. I have basically zero military (just few heroes and tamed beasts), but a 5 thriving cities with high population. I also got 3-4 world achievement buildings, don't know if they fit in the calculations.