When Ali assumed caliphate, he had deposed the Egyptian governor, Abi Sarah in favour of the famous Ansar chief, Qais bin Sa'd bin Ubaida. This seasoned warrior of Islam, proud of his lineage and sincerely devoted to the Hashimites, was famed for his wisdom and diplomacy, qualities which were to stand him in good stead during his governorship. Muawiya tried to take Qais bin Sa'd to his side, but failed. Thus, Muawiya spread a rumour that Qais had joined the party of Muawiya. Ali had full trust on Qais, but his men wanted to appoint another governor in Egypt. Ali then appointed Muhammad bin Abu Bakr as the governor of Egypt. The ground in Egypt had certainly been prepared well in advance by Muawiya's propaganda. In the meantime, Muawiya sent 6000 soldiers in command of Amr bin al-A'as in Egypt. Realising the failure of Muhammad bin Abu Bakr, Ali now sent hasty orders to Ashtar in Iraq, appointing him the new governor of Egypt. Muawiya bribed the chief of Qulzum in whose house Ashtar would almost stay on the way to Egypt, to poison the general. So Ali lost his most staunch of all his supporters, Ashtar, not on the battlefield, but at the table of a man whose loyalty had been bought by Muawiya and who had poisoned the honey which he offered his guest. Ali had no alternative but to ask Muhammad bin Abu Bakr to continue in the office and to hang on as best he could. Ali was yet able to send 2000 crack troops under the command of Tujibite Kinana by way of reinforcement. Other authorities maintain that once again, the Kufans would do nothing to help Ali and that, after fifty days of haranguing them from the pulpit, Ali still had managed to muster only 200 volunteers. These he is said to have sent to Egypt, but the long delay had already proved fatal. Hardly had they left Kufa when the news came of the total defeat of Muhammad bin Abu Bakr's forces and his ugly death. Having fled from the battlefield, Muhammad took shelter in some nearby ruins where he was discovered by Muawiya bin Hudaija, who dragged him out and slain. His corpse was wrapped in an ass-skin and burned. The ignominious end of Muhammad bin Abu Bakr sealed the fate of Egypt for Ali. Muawiya occupied Egypt and appointed Amr bin al-A'as as his lieutenant to rule it in his name, and the newly conquered country, with its immense rich resources became incorporated in the Syrian empire.
When Egypt was lost, in one of his sermons to the Kufans, Ali summed up the loss in these words: "O ye people! In the hour of need you have kept aloof from me, like a restive camel when it casts its burden. Lo and behold! The son of Abu Bakr falls, and with him, Egypt too." Things hence became bleak and dreary. Alarmed by the news of Ali's depressive state of mind, his cousin Abdullah bin Abbas, the governor of Basra, set out for Kufa, hoping to rally Ali's spirit. Muawiya immediately took advantage of Ibn Abbas's absence from Basra to send an expedition of 2000 horses under the command of Ibn Hadrami. The then deputy governor of Basra, Ziyad bin Abihi, found himself unable to oppose the invader and took to flight, seeking refuge with the neighbouring tribe of Banu Azd. From here he wrote to Ali, asking for aid. Ali sent such troops as he could mustered, and with this reinforcement, Ziyad was able to give battle to the Syrians, near Basra, where he routed the enemy. Basra thus reclaimed for Ali, who reappointed Ibn Abbas as governor, but Ali's hold over the city remained precarious. The expedition to Basra was Muawiya's first attempt at invading Ali's territory and although the defeat inflicted on Syrian forces was decisive the victory for Ali was to prove only a temporary one.
In the same year of 37/659, a section of the Kharijis hatched rebellion against Ali, led by Khirrit bin Rashid of Banu Najiya. Ali attempted to appease the new rising by inviting Khirrit to come and discuss the matters with him, but Khirrit and his followers left the town in disgust and fled to Ahwaz. Here he incited the Iranians, the Kurds and the Christians to withhold payment of taxes to Ali's government. Other disgruntled warriors soon joined him and in a short time he had raised a considerable army, which invaded and occupied Fars, defeating the Alid governor who sought safety in flight. Ali now sent his Kufan general Muquil bin Qais al-Tamimi against Khirrit, who was subdued at Ramhurmuz. In all, Ali was forced to send Muquil against Khirrit twice more. In the third and last encounter, Khirrit and the 170 soldiers, who made up his personal force, were wiped out to a man. Ali appointed Ziyad, the deputy governor of Basra, to rule over Fars.
Grown fat on the resources of Egypt, the Syrians now began to cast covetous eyes on Iraq. Muawiya accordingly deputed Noman bin Bashir to ravage Ayn Tamr, Sufian bin Awf to attack Hit and Anbar, Abdullah bin Masada al-Fazari to invade Taima and Dahhak bin Qais to subdue Qutqutana. According to Yaqubi (d. 284/898) in "at-Tarikh" (Beirut, 1960) and Waqidi (d. 207/822) in "Kitab al-Maghazi" (ed. von Kremer, Calcutta, 1856), Muawiya himself came out with these troops to lead them towards Iraq, going as far as Tigris, before returning to Damascus. Apparently these were plundering expeditions, their ostensible aim was to harass Ali. Ali went forth himself into the field almost unattended. On this the men of Kufa, partly from shame, partly lured by promise of increased stipends, marched to the defence of their frontier. One of Ali's commanders, with a flying column, pursued the raiders back into the heart of Syria as far as Balbek; and thence turning northward, escaped by Rakka again into Iraq. On the other side, Muawiya made an incursion right across Iraq, and for some days remained encamped on the banks of Tigris. After leisurely inspecting Mosul, he made his way back to Damascus unmolested.