In pre-Islamic times people lived in tribes and loyalty was to the tribe in quite an amoral way. That was because if your tribe did not protect you, then you would have no protection at all as an individual.
It could be said that with Islam came the origins of nationhood.
Tribes can be people of the same race.
Different tribes can agree to put their differences aside and become a nation.
Do they have to be of the same race?
http://en.wikipedia.org/wiki/Ummah suggests that a nation just means people of different races agreeing to regard themselves as one despite tribal and racial differences as long as they agree to adhere to a common set of rules and a common outlook on morality.
From this idea came the idea of a nation being bigger and better than a tribe, because only a nation is in fact small enough to care and big enough to matter.
Apart from giving the warring tribes of Arabia a bigger and better concept of human organisation, I like to think that the Koran is a kind of tick list of success or failure. The more your society adheres to it, the more likely you are to be successful.
Of course there are plenty of Muslim nations who do call themselves Muslim but do not in fact do what the Koran says.
There are even nations that are unconsciously Muslim, and I would suggest that Britain in a previous age was more Muslim then than now, even though there are more Muslims here now.
The more Koranic commandments your society follows, the more likely it is to be peaceful and flourishing.
The more it strays from the Koran, the more disordered and self-destructive it becomes.
Gaddafi's troubles had a lot to do with not fixing the divisiveness of the tribal system in Libya. He thought it was enough to prefer his own dominant tribe, when it was in fact necessary as an act of nation-building to abolish the tribal system altogether.
We too are also far astray from the right path.