The Siege of al-Taʾif
The Prophet ﷺ besieged Thaqif in their impregnable fortress at al-Taʾif after Hunayn for about a month, then lifted the siege and prayed: "O Allah, guide Thaqif and bring them." Their delegation came as Muslims a year later, without fighting.
The remnants of Hawazin and Thaqif took refuge after Hunayn in the impregnable fortress of al-Taʾif, which they had stocked with a year's provisions. The Prophet ﷺ besieged them and struck the fortress with the catapult (manjaniq) — the first use of it in Islam — and a number of Companions were struck by the fortress's missiles.
When the siege dragged on, he ﷺ consulted Nawfal ibn Muʿawiya al-Dili, who said: A fox in its den; if you stay upon it you will take it, and if you leave it, it will not harm you. So he ordered departure. The Companions said: Let us supplicate against Thaqif; he said: "O Allah, guide Thaqif and bring them."
Allah answered his prayer; not a year passed before the delegation of Thaqif came to Madinah declaring their Islam, so al-Taʾif became Muslim without being taken by the sword. In the account was the fiqh of balancing the possible against the hoped-for, and the effect of supplication where armies do not reach.
Note — differing reports on the date: The siege was in Shawwal 8 AH and lasted about a month; its days are not agreed upon.