The Prophet (peace and blessings of Allah be upon him) and the establishment of the Islamic society
Question

How and with degree of success was muhammed(s.a.w)able to establish a stable community in medinah 632ce.
Praise be to Allah.Undoubtedly the society that was established by the Prophet (peace and blessings of Allah be upon him) in Madeenah was an example of a stable and secure society. That was manifestly apparent from the moment the Prophet (peace and blessings of Allah be upon him) first set foot in Madeenah and stated to form the Islamic state. The security and stability of this society were due to a number of reasons and factors, including the following: 
The Prophet (peace and blessings of Allah be upon him) built the mosque in Madeenah as soon as he arrived there, which helped to establish a focal point to which people could turn when calamities struck, and a place where the Muslims could gather to meet one another and find out about one another, so they could find out who was sick and go to visit them, attend the funerals of those who died, help their poor and arrange marriages for those who were single.  
These are some of the ahadith concerning that: 
It was narrated from Anas ibn Maalik (may Allah be pleased with him) that when the Messenger of Allah (peace and blessings of Allah be upon him) came to Madeenah, he ordered that the mosque should be built, and he said, “O Banu Najjaar, name me a price for this garden of yours.” They said, “No by Allah, we will not seek its price except from Allah.” 
(Narrated by al-Bukhari, 2622; Muslim, 524) 
It was narrated that al-Bara’ ibn ‘Aazib said: “[The verse] ‘and do not aim at that which is bad to spend from it’ [al-Baqarah 2:267 – interpretation of the meaning] was revealed concerning us Ansaar. We used to own date palm trees. A man would bring (the harvest) from his date palms, whether it was a little or a lot. A man would bring one or two bunches of dates and hang them in the mosque. Ahl al-Suffah – or according to a report narrated by Ibn Maajah, the poor among the Muhaajireen – had no food, so if one of them got hungry he would come and strike the bunch with his stick, and ripe and unripe dates would fall, and he would eat them. But there were some uncharitable people who would bring a bunch of dates that contained rotten or dried-up dates, or a bunch that was damaged, and hang it up. Then Allah revealed the words (interpretation of the meaning): 
“O you who believe! Spend of the good things which you have (legally) earned, and of that which We have produced from the earth for you, and do not aim at that which is bad to spend from it, (though) you would not accept it save if you close your eyes and tolerate therein” [al-Baqarah 2:267]
He said: if any one of you were to be given something like they gave, he would not accept it unless he did so with his eyes closed or out of shyness. He said, after that one of us would bring the best dates that he had.
Narrated by al-Tirmidhi, 2987; Ibn Maajah, 1822. Classed as saheeh by al-Albani in Saheeh al-Tirmidhi, 2389. 
Secondly: 
The Prophet (peace and blessings of Allah be upon him) established brotherhood between the Muhaajireen (the Emigrants who had come from Makkah) and the Ansaar (helpers, the Muslims in Madeenah). This action strengthened the bonds between the members of the Madeenan society in a manner previously unheard of. The Prophet (peace and blessings of Allah be upon him) established bonds of brotherhood between non-Arabs and Arabs, between free men and former slaves, between people of Quraysh and members of other tribes. So the society became one entity, after which it was not surprising that an Ansaari would ask a Muhaajir to take half of his wealth, or an Ansaari would offer to divorce one of his wives so that a Muhaajir could marry her, or a Muhaajir would inherit from an Ansaari, because of the strength of the bonds between them. Then inheritance between them was abrogated by the verse on inheritance, but the Ansaar were encouraged to bequeath something to them. This was an exemplary society.
There follow some of the ahadith concerning that: 
1 – It was narrated that ‘Abd al-Rahmaan ibn ‘Awf (may Allah be pleased with him) said: When we came to Madeenah, the Messenger of Allah (peace and blessings of Allah be upon him) established bonds of brotherhood between me and Sa’d ibn al-Rabee’. Sa’d ibn al-Rabee’ said: “I am the wealthiest of the Ansaar, so I will give you half my wealth, and see which of my wives you would prefer, I will divorce her for you, and when she becomes permissible you can marry her.” ‘Abd al-Rahmaan said to him, “I do not need that. Is there a marketplace where people trade?” He said, “The marketplace of Qaynuqaa’.” So the next day ‘Abd al-Rahmaan went there and took some cottage cheese and ghee, and he did that the next day. It was not long before ‘And al-Rahmaan came with traces of yellow (perfume) on him. The Messenger of Allah (peace and blessings of Allah be upon him) said, “Have you gotten married?” He said, “Yes?” He said, “To whom?” He said, “A woman from among the Ansaar.” He said, “How much was the mahr?” He said, “A gold piece equal in weight to a date stone (or a date stone of gold).” The Prophet (peace and blessings of Allah be upon him) said to him, “Give a wedding feast (waleemah), even if with one sheep.” 
Narrated by al-Bukhari, 1943. 
2 – It was narrated from Ibn ‘Abbaas (may Allah be pleased with him) that when the Muhaajireen came to Madeenah, a Muhaajir would inherit from an Ansaari to the exclusion of the Ansaari’s own relatives, because of the bonds of brotherhood that the Prophet (peace and blessings of Allah be upon him) had established between them. When the verse “And to everyone, We have appointed heirs” [al-Nisa’ 4:33 – interpretation of the meaning] was revealed, that was abrogated. And the phrase “To those also with whom you have made a pledge (brotherhood)” [al-Nisa’ 4:33 – interpretation of the meaning] has to do with the covenant of helping, supporting and advising one another. So the rights of inheritance no longer apply, but they may bequeath to one another. 
Narrated by al-Bukhari, 2170. 
Thirdly: 
Zakaah was prescribed in the second year of the Hijrah, which made the rich and poor more equal and increased the coherence of the Madeenan society, and the bonds of brotherhood for the sake of Allah became stronger than before. Indeed, the matter went further than zakaah to include voluntary charity. 
It was narrated that Anas ibn Maalik (may Allah be pleased with him) said: Abu Talhah was the wealthiest of the Ansaar of Madeenah in terms of palm trees, and the dearest of his wealth to him was (the garden of) Bayraha’, which was opposite the mosque. The Messenger of Allah (peace and blessings of Allah be upon him) used to enter it and drink from good water that was to be found there. Anas said: When the verse “By no means shall you attain Al-Birr (piety, righteousness — here it means Allah’s reward, i.e. Paradise), unless you spend (in Allah’s Cause) of that which you love” [Aal- Imraan 3:92 – interpretation of the meaning] was revealed, Abu Talhah got up and went to the Messenger of Allah (peace and blessings of Allah be upon him) and said, “O Messenger of Allah, Allah says ‘By no means shall you attain Al-Birr (piety, righteousness — here it means Allah’s reward, i.e. Paradise), unless you spend (in Allah’s Cause) of that which you love’ and the dearest of my wealth to me is Bayraha’. (I give it in) charity for the sake of Allah, hoping to earn its reward with Allah, so dispose of it, O Messenger of Allah, as Allah shows you.” The Messenger of Allah (peace and blessings of Allah be upon him) said, “Well done, that is a profitable deal, that is a profitable deal. I have heard what you said and I think that you should distribute it among your relatives.” Abu Talhah said, “I shall do that, O Messenger of Allah,” and he distributed it among his relatives and the sons of his paternal uncles. 
Narrated by al-Bukhari, 1392; Muslim, 998 
So the signs of harmony appeared among the Muslims in Madeenah, and the Muhaajireen recognized the rights that their Ansaar brothers had over them. There are a number of ahadith concerning that, including the following:
 It was narrated that Anas said: When the Prophet (peace and blessings of Allah be upon him) came to Madeenah, the Muhaajireen came to him and said, “O Messenger of Allah, we have never seen any people more generous when they have the means and more helpful when they have little than the people among whom we have settled. They have looked after us and they have let us join them and share in all their happy occasions, to such an extent that we are afraid that they will take all the reward. The Prophet (peace and blessings of Allah be upon him) said, “Not so long as you pray for them and praise them.” 
Narrated by al-Tirmidhi, 2487; classed as saheeh by al-Albani in Saheeh al-Tirmidhi, 2020.
Allah created loved between the hearts of the people of Madeenah, and love for the sake of Allah was one of the symbols of the people that Allah enjoined upon them and made it one of the signs of perfect faith.
It was narrated from Anas (may Allah be pleased with him) that the Prophet (peace and blessings of Allah be upon him) said: “None of you truly believes until he loves for his brother what he loves for himself.” 
Narrated by al-Bukhari, 13; Muslim, 45. 
It was narrated that al-Nu’maan ibn Basheer said: The Messenger of Allah (peace and blessings of Allah be upon him) said: “The believers, in their mutual mercy, love and compassion, are like a (single) body; if one part of it feels pain, the rest of the body will join it in staying awake and suffering fever.” 
Narrated by al-Bukhari, 5665; Muslim, 2586.