After the fall of Mecca Kaaba came under the control of the Prophet (S.A.W). The breaking of the idols and banning entries of the non-Muslims in it caused bitter reactions on the non Muslim population of Mecca and its surrounding hamlets, for this was the holy place of worship for them. The hypocrites too who had embraced Islam for their own personal gains or out of fear were also not happy with this ban because in their hearts they were still idol worshipers and were having sympathies with the infidels. Among these people were two powerful Beduin tribes of Bani Hawazin and Bani Saqeef. These two tribes joined hands with Bani Nasr, Bani Saad, Bani Husham and Bani Halal to fight and take back their place of worship. The new converts who had embraced Islam only after the fall of Mecca also assured them of all help. Thus a force of twenty thousand people gather under the leadership of Malik Bin Awf to fight the Muslims. They decided to attack them at Tayef outside Mecca when the Prophet (S.A.W) and his followers leave Mecca for Madina.
When the Prophet (S.A.W) learned about the impending attack, he left Mecca to face them with ten thousand Muslims, who had accompanied him from Madina. Some two thousand newly converts from Mecca including some freed slaves too volunteered to fight for Islam. Ali (A.S.) as usual was given the banner of Islam and asked to lead the army. The Muslims reached the valley of Hunain at mid night. The path of Hunain to Taif was so narrow that men could walk on it only in singles. Even camels and horses could walk with difficulty. The enemies had planned their attack on the Muslims from this place. They hid their archers here and had ordered them to attack the Muslims when they cross this narrow path, from both the sides, as well as from the front. Their strategy worked and as the Muslims entered the narrow path the infidels attacked them from three sides. The Muslims shocked by this sudden attack fled without putting any resistance. The first division that fled was the one commanded by Khalid Bin Waleed. The tribe of Bani Saleem from Mecca which had just embraced Islam followed them. Umar Ibnul Khattab too ran away leaving the Prophet (S.A.W) alone. When Abu Qatada lamented on his deserting the Prophet (S.A.W), Umar replied that it was the will of Allah.
In few moments the entire Muslim army fled leaving the Prophet (S.A.W) alone with Ali (A.S.), Abbas (Prophet (S.A.W)s uncle), Aqueel (Ali (A.S.)s brother), Abdullah Ibne Zubair, Zubair Ibne Awam, Usman Ibne Zaid and Abu Sufian Ibnul Harris. The Prophet (S.A.W) asked his uncle to call the Muslims and Abbas shouted with full-throated voice, "O Helpers (People of Madina) O People of Samra (those who had taken the oath of Allegiance to the Prophet (S.A.W) under the tree of Samra, known as Baitur Rizwan, at the time of signing the peace treaty of Hudaibia) where are you running away. The Prophet (S.A.W) of Allah is here. Return, come back, where are you going. The Apostle of The Lord is here. Return where are you going." But nobody paid any attention to Abbass voice and nobody returned. Abu Sufian gleefully taunted the Prophet (S.A.W) and said, "They will not stop till they reach the sea shore." Many of the new converts from Mecca had also gathered near Abu Sufian to congratulate him for the defeat of the Muslims. They said that the magic spell of the lying Prophet had broken now. But the call that Abbas continued to give did have some effect and some Muslims returned. Ali (A.S.) divided this small force into three divisions. One division was asked to Protect the Prophet (S.A.W), the other was asked to check from the rear and the third division he took with him to attack the attackers. Ali (A.S.) fought and fought till he slew their commander Abu Jendal, and got seriously hurt. But he pounced upon the enemys ranks and killed thirty of them. The rest fled, and the war was won. Malik Ibne Awf fled to Taif where he was given asylum. Abu Qatada who had also fled with the rest of the Muslims found Umar Ibnul Khattab among the deserters of the Prophet (S.A.W), when Abu Qatada asked as to why did he flee Umar replied, "What to do? Allah wished so" [Sahih Bukhari, Chapter 17, page 50].
The people of Tayef who were known for their bravery and courage attributed this strength and success to an idol called "Al-Lat". The Prophet (S.A.W) in order to correct them and show them that the hand-made idols cannot have power to give anything and are themselves perishable, sent some of the Muslims to break the idol. But the people of Tayef did not allow the Muslims to break the idol and chased them away. The Prophet (S.A.W) then sent Ali (A.S.) who on entering the city broke not only Al-Lat but destroyed all the pagan symbols. This greatly hurt the feelings of Bani Khusham whose leader Shahab came out to challenge Ali (A.S.) and was slain. Seeing their leader killed the members of Bani Khasham surrendered. Then came the tribes of Bani Thakeef and Bani Hawazin but they too were defeated by Ali (A.S.). Ali (A.S.) then marched towards Tayef and the people of Tayef too surrendered before him.
In the year 9 A.H. the tribes of Wadi-ul-Ramal attempted to attack Madina. The Prophet (S.A.W) sent two expeditions to check them but they failed. The Prophet (S.A.W) then deputed Ali (A.S.) to tackle them. Ali (A.S.) went and finished them.
When Ali (A.S.) was returning from this expedition he saw the Prophet (S.A.W) waiting outside Madina to receive him. Ali (A.S.) immediately jumped from his horse and came to the Prophet (S.A.W) on foot. The Prophet (S.A.W) was so happy with the victory that Ali (A.S.) had achieved that he made Ali (A.S.) mount the horse again and said, "O Ali, Allah and His Prophet have accepted your services" On hearing these words Ali (A.S.) wept in joy.
The Prophet (S.A.W) had hardly passed some days in peace when he got the news that the Roman emperor Heracles was mobilizing a huge army to attack Madina and many of the Arab tribes were helping him. The Prophet (S.A.W) wanted to stop them on their way but the situation in Madina itself was so sensitive that he could not leave the place. There was famine in Hejaz, Tayef and Yemen and the hypocrites were spreading the rumour that the famine was Allahs curse on the Muslims and He wants to finish them. Another rumour that the hypocrites had spread was that the Roman army was very strong and that the defeat of the Prophet (S.A.W) was certain. These groups were being prepared to demoralize the Muslims and the chances of their revolting against the Prophet (S.A.W) in his absence was certain.
The Prophet (S.A.W) was now compelled to fight on both the fronts. He therefore appointed Ali (A.S.) as the governor of Madina with the permission to lead the prayers and perform all other duties the Prophet (S.A.W) himself performed. The Prophet (S.A.W) had hardly gone some distance when the hypocrites led by Abdulla Ibne Ubay started spreading another rumour that the Prophet (S.A.W) had deliberately avoided Ali (A.S.) as he had some doubts about his integrity. Ali (A.S.) felt very sad at this news. He rushed towards the Prophet (S.A.W) to confirm it. On meeting the Prophet (S.A.W), Ali (A.S.) said, "You are leaving me behind in the company of women and children?" The Prophet (S.A.W) consoled Ali (A.S.) and condemned the rumour mongers and the liars. He warned Ali (A.S.) to be vigilant against these hypocrites and enemies of Islam who were looking for an opportunity to revolt against him and this was the reason why they did not want him to be there in Madina, and that is the reason why he (Prophet) had kept himy back in Madina so that he may keep them in check and also look after the Muslim families. The Prophet (S.A.W) further assuring Ali (A.S.) of his confidence and love for him said, "When they can call me an epileptic, magician, neoromant and liar they can also cast aspersions on you. O Ali, you are to me what Haroon was to Moosa" [Sahih Bukhari]. Ali (A.S.) returned convinced to Madina and the Prophet (S.A.W) proceeded towards Tabuk where he stayed for twenty days till the governor of Ila approached him and signed a peace treaty.
The march to Tabuk had its own significance for it showed the characters of the followers of Islam. When the Prophet (S.A.W) ordered them to march, they just marched even without proper ammunitions and enough food to last the journey. Some Muslims took only one date as their food for the whole day. The Prophet (S.A.W) generally tied a stone on his belly so as not to feel hungry. Abu Zarr-e-Ghaffari was another such soldier of the Prophet (S.A.W). The camel that he was riding was very weak and could not keep pace with the rest of the marchers. Gradually Abu Zar was left behind from the army, and the people thought that Abu Zar too had deserted the Prophet (S.A.W) as some of them had done earlier, whenever the Prophet (S.A.W) was told about anybodys desertion he said, "Let him go away. If there is anything good in him Allah will make him return, if there is nothing good in him it is better he has gone." The Prophet (S.A.W) gave the same answer when the people informed him about Abu Zars missing also.
But Abu Zar had not deserted the Prophet (S.A.W). When he saw that because of his weak camel he has been left far behind and that it would not be possible for him to be with them on the battlefield, he climbed down from the camel and leaving it behind he set on foot to be with the Prophet (S.A.W) soon. He walked on the burning sand hungry and thirsty. On the way near a hilly place he saw some water, but instead of drinking it he collected it for the Prophet (S.A.W) saying to himself that how could he quench his thirst when his dearest friend the Prophet (S.A.W) is thirsty. Filling his water-skin and slinging it on his shoulders he hastened towards the Prophet (S.A.W). When the Muslims saw somebody coming towards them informed the Prophet (S.A.W) who said it must be Abu Zar, and when the man came nearer the Muslims recognised him to be Abu Zar. He was so exhausted due to hunger and thirst that he was about to collapse. The Prophet (S.A.W) ordered his men to give him some water to drink, but Abu Zar refused saying with a feeble voice that he himself had some water with him. When the Prophet (S.A.W) asked him as to why did he not drink that water as he was about to die of thirst Abu Zar replied, "How could I drink any water before the Prophet (S.A.W) of Allah has not drunk."