In 5 AH (627 CE), a confederate force of about ten thousand marched on Madinah. Tradition credits Salman al-Farisi with suggesting a trench. The Prophet ﷺ dug and carried earth himself, hungry like everyone else, and the siege failed.

In 6 AH (628 CE) he set out for Umrah with about fifteen hundred companions and camped at Hudaybiyyah. Negotiations produced a treaty whose terms looked unfavourable to many Muslims: they would return that year and come back the next. Yet it brought peace with Quraysh. The Qur'an revealed in connection with it opens: “Indeed, We have given you a clear victory” (48:1).