The enemies of the Muslims this time created a united front. This culminated in a solemn pact of alliance among the five principal tribes. When the news of this tremendous mobilization reached the Muslims in Medina, it struck them all with panic. It was Monday, the 1st Shawal, 5/February 24, 627 when a gigantic army under the command of Abu Sufian besieged Medina. The number of this invading force is variously estimated at something between ten and twenty-four thousands, the largest single army ever mustered on Arabian soil. The Muslims had fortified Medina from three sides, but it was exposed from one side. Salman al-Faras, who knew far more of the techniques of warfare than was common in the Peninsula, advised the digging of a dry moat around Medina and the fortification of its buildings within. Following the idea of Salman al-Faras, Muhammad ordered the trenches to be dug in that open end of the city, and thus it is called the battle of Ditch (khandaq). The word khandaq is, no doubt, regarded as the Arabicized version of the Persian word kandah(dug-up). The ditch ran from Sheikhein to the hill of Zubab, and thence to Jabal Banu Ubaid. All these hills were included in the area protected by the ditch, and on the west the ditch turned south to cover the left flank of the western of the two hills, known as Jabal Banu Ubaid. Once the digging of the ditch was completed within six days, the Muslims established their camp just ahead of the hill of Sila'a. Their total strength was 3000 which included hypocrites whose fighting value and reliability were uncertain.
The invading force fell on Medina like an avalanche, where they found an impassable ditch surrounding the whole city, thus they failed to subdue the besieged. The Muslims, after transferring their women and children to securer places, manned their fortifications so well that the siege continued for over a month. Food ran out, essential supplies were exhausted, and when the pang of hunger became unbearable, the besieged warriors stilled them by tying stones to their empty stomachs. The armies were effectively separated by the trench around Medina, but known champions in arms occasionally challenged each other to single combat. One of them was a famous Arab wrestler, named Amr bin Abdud-wudd. He found a point where the ditch was narrow, and succeeded in entering it on a fast jumping horse. He strutted forth haughtily and dared the Muslims to send a man against him. Ali rode out at once and laid him low with a single stroke. Made with anger the invaders launched another furious attack to storm the trench, but were thrown back as before. Winter was approaching; the supplies of the besiegers were also running short and murmurs of discontent arose among their hordes. One night the wild wind terribly rose and soon gathered into a storm. It uprooted their tents, scattered their provisions, scared their mounts, and, what with the dark and unusual cold, spread so much terror and confusion in the camp that when the day dawned, the siege had been lifted and the invaders withdrew from the field. Each man carried as little as his camel, horse, or shoulders could bear and began to move while the storm continued to rage. The encounter at the battle of Ditch was the last time that the town of Medina ever faced an invader. After this battle, the strength of her enemies was for ever broken.