the Fatwa Department Research Committee - chaired by Sheikh `Abd al-Wahhâb al-Turayrî
The answer to this question can be found in the Qur'ân and Sunnah.
1. Moses (peace be upon him)
Moses (peace be upon him), in his capacity as a prophet, called the Children of Israel to follow him into exile from Egypt, where they were facing brutal persecution. They agreed to follow him and left with him under his leadership. His authority stemmed from their belief in him.
After the flight from Egypt, a covenant was then taken from the Children of Israel at Mount Sinai.
Allah says: "And remember We took your covenant and We raised above you the Mount, saying: 'Hold firmly to what We have given you and bring (ever) to remembrance what is therein: Perchance ye may fear Allah.' [Sûrah al-Baqarah: 63]
Allah say: "And remember We took your covenant and We raised above you the Mount, saying: 'Hold firmly to what We have given you, and hear Our word'." [Sûrah al-Baqarah: 93]
Moses did not found a state. He died while he and his people were still wandering around in the desert.
Abû Hurayrah relates that at the time of death, Moses (peace be upon him) requested from Allah to let him die close to the Holy Land so that he would be at a distance of a stone's throw from it. Abû Hurayrah adds: Allah's Messenger (peace be upon him) said: "If I were there, I would show you his grave below the red sandhill on the side of the road." [Sahih Al Bukhârî (1253, 3155) and Sahîh Muslim (4374, 4375)]
2. David (peace be upon him)
Kingship was established for Israel by a prophetic decree – in other words by way of revelation –in which Saul was appointed by their prophet to be king over them.
It was the Children of Israel who requested from their prophet that Allah appoint a king for them. Allah says: "Have you not turned your attention to the Chiefs of the Children of Israel after (the time of) Moses? They said to a prophet that was among them: "Appoint for us a king, that we May fight in the cause of Allah." [Sûrah al-Baqarah: 246]
The Qur'ân does not state the name of this prophet, only that he came after Moses. Biblical sources say that he was Samuel.
Allah says: "Their Prophet said unto them: Lo! Allah hath raised up Saul to be a king for you. They said: How can he have kingdom over us when we are more deserving of the kingdom than he is, since he hath not been given wealth enough? He said: Lo! Allah hath chosen him above you, and hath increased him abundantly in wisdom and stature. Allah bestows His sovereignty on whom He will. Allah is All-Embracing, All-Knowing.
"And their Prophet said unto them: The sign of his kingdom is that there shall come unto you the ark wherein is peace of reassurance from your Lord, and a remnant of that which the house of Moses and the house of Aaron left behind, the angels bearing it. Herein shall be a sign for you if (in truth) you are believers." [Sûrah al-Baqarah: 247-248]
We can see from these verses that the people were not happy with the choice of Saul, but they submitted to it as a religious duty on the strength of their faith, since it was the pronouncement of their prophet.
The Qur'ân tells us that Allah then gave the kingship to David (peace be upon him) after Saul led the armies in battle against Goliath and David slew Goliath.
Allah says: "So they routed them by Allah's leave and David slew Goliath; and Allah gave him the kingdom and wisdom, and taught him of that which He willed. And if Allah had not repelled some men by others the earth would have been corrupted. But Allah is a Lord of Kindness to (His) creatures." [Sûrah alBaqarah: 251]
The Qur'ân does not go into the details of how the order was given to transfer kingship from Saul to David. Biblical sources state that it was again by the order of the prophet Samuel.
3. Solomon (peace be upon him)
Solomon (peace be upon him) succeeded David to the throne as his heir.
Allah says: "And Solomon was David's heir. He said: 'O people! We have been taught the speech of birds, and on us has been bestowed (a little) of all things: this is indeed Allah's grace manifest'." [Sûrah al-Nahl: 16]
4. Joseph (peace be upon him)
Joseph (peace be upon him) was never a head of state. He was appointed by the ruler of Egypt to high political office after suggesting to the ruler that he would be well-suited for the post. Joseph was essentially like a Minister of Finance.
The account of his appointment is given in the Qur'ân:
"So the king said: 'Bring him to me; I will take him specially to serve about my own person.' Therefore when he had spoken to him, he said: 'Be assured this day, you are, before our own presence, with rank firmly established, and fidelity fully proved!'
"(Joseph) said: 'Set me over the store-houses of the land: I will indeed guard them, as one that knows (their importance).'
"Thus did We established Joseph with power in the land, to take possession therein as, when, or where he pleased. We bestow of our Mercy on whom We please, and We do not let the reward of those who do good be lost." [Sûrah Yûsuf: 54-57]
5. Muhammad (peace be upon him)
Muhammad (peace be upon him) was offered an oath of loyalty and allegiance by the tribal leaders and community representatives of Madinah while he was still in Mecca. They sent a delegation to him and invited him to come to Madinah and accept leadership of the city-state, which had been wracked by years of civil strife. He accepted their invitation and their covenant.
This is known as the Second Oath of `Aqabah. Ibn Ishâq provides us with a long narration from Ka`b b. Mâlik about how the Muslims from the tribes of `Aws and Khazraj went to Madinah accompanied their polytheistic countrymen to pilgrimage in that year to give the pledge. This account can be read in Sîrah Ibn Hishâm (2/81-85), Musnad Ahmad (3/460), Târîkh al-Tabarî (2/357-363), and al-Bayhaqî's Dalâ’il al-Nubuwwah (2/442).
In brief, the delegation from the tribes of `Aws and Khazraj assembled to meet with the Prophet (peace be upon him) in Mecca. When he came, he was accompanied by his uncle, al-`Abbâs b. Abd al-Muttalib. At that time, al-`Abbâs was still on the religion of his people, but he wished to attend to the affairs of his nephew and make certain of them.
Al-`Abbâs was the first to speak: "O people of Khazraj!" (The `Arabs used to call people from that area Khazraj, whether they were from the tribe of Aws or the tribe of Khazraj) "Muhammad is one of us, as you know, and some of our people who hold the opinion that our people hold about him have been protecting him. So he has standing among his people and is protected in his own land. He has refused to do anything except to join you. So, if you feel that you will fulfill what you have invited him for and that you will protect him from those who will go against him then you shall bear the responsibility of that. But if you feel that you will surrender him or forsake him after he comes to you, then abandon him right now, for he has standing here in his own country among his own people and he has protection."
They said to him: "We hear what you say. Now speak, O Messenger of Allah and take for yourself and your Lord what you wish."
Allah’s Messenger (peace be upon him) spoke. He first recited from the Qur’ân and called the people to Allah and awakened there desire for Islam. Then he said: "Give me your pledge that you defend me as you would defend your wives, and your children."
After they voiced their agreement, Allah’s Messenger (peace be upon him) smiled and said: "My blood and yours is one. My responsibility and yours is one. I am of you and you are of me. I will fight those who fight you and make peace with those who make peace with you."
Allah’s Messenger (peace be upon him) said: "Send forth to me twelve of your leaders to represent their people." So they sent forth twelve people, nine from the tribe of al-Khazraj and three from the tribe and al-Aws.
This is how Prophet Muhammad (peace be upon him) became leader of the city-state of Madinah. He was invited to do so by its people.
And Allah knows best.
Source: Islam Today