The Prophet (peace and blessings be upon him) united the Muslim Ummah by various ways, which represent the means for the unity of Muslims in all ages. Such means include that the Muslims should be faithful to their message and to their religion. They should establish the doctrine firmly in their hearts, seek knowledge and science, abhor injustice, and realize that their glory and supremacy are in being close to Allah, looking forward to Allah’s satisfaction and Paradise), having earthly pleasures minimized in their eyes, and having all their mottos stemming from their belief.
In this regard, Sheikh Ahmad Ash-Sharbasi, professor of `Aqeedah and Philosophy at Al-Azhar University, has stated the following: Prophet Muhammad (peace and blessings be upon him) gathered his nation and united its decisions because he is the Seal of the Prophets and the leader of the Messengers sent by Allah. He is the leader of all who fight for the sake of Allah and he was sent as a mercy to all humanity and supported by the care of Allah the All-Mighty.

And to explain I will say briefly that the noble Prophet (peace and blessings be upon him) was able to fulfill such unity and solidarity thanks to many causes and means, such as the strength of his character, his sincere devotion to his message, as well as his detestation of the false idols that prevailed at that time; and, moreover, he implanted the hearts with a creed that was superior to the false and trivial pagan beliefs.
he lightened the hearts with the light of believing in the Glorious Creator Who owns all that is in the heavens and on the earth. He firmly fixed this faith, practically and continuously, by the acts of worship his Lord revealed to him, such as prayers, fasting, Zakah, Hajj, and other kinds of good deeds.
In addition to this, he purified the souls of his people of grudges and hatred; there was no room for aggression or injustice, no room for pride or insults, but rather brotherhood, love and equality because they were of one origin, and there was no privilege of an Arab over a non-Arab except through piousness.
Besides, he taught them that they have no actual power or might; that when they are self-conceited they will lose, but when they are proud of their Creator they will succeed and prosper; and that glory is to Allah, His Messenger and to the believers. This is why the Qur’an states, (And hold fast, all of you together, to the cable of Allah, and do not separate…) (Al `Imran 3: 103)
From such ways, also, the value of life and its pleasures was minimized in their eyes. As long as one looks down upon life, his humanity increases, and he deserves to gather all human beings under the roof of love and faithfulness. He also made them look forward to a marvelous Heaven and to live for an eternal life to come after this temporary life. And since for such causes competitors must work together and diverse people must cooperate, how will be the case with those with a common identity?
Moreover, he dyed the patriotic motive with a religious one and stated that to love your homeland is to believe, and to defend your property is part of good religion.
Such a strong heavenly bond joined all parties with a bond of solidarity and agreement, for they could not have authority over their lands and defend their sovereignty to please their Lord unless each and every one of them was a help and support to his brother, for one Muslim to another Muslim is like a solid wall (of bricks) supporting each other.
Finally, the Prophet (peace and blessings be upon him) succeeded in uniting his Ummah and people because he turned them into a pious and faithful nation that works for its lifetime as if it will live forever and works for the Hereafter as if death will end it tomorrow. Therefore, this religion will only prosper by what caused its prosperity at the very beginning; as for those who are lagging behind, if they want to come forward, they have the way right in front of them.