The siege of Ta’if took place as a result of the enemy Thaqif had retreated to their fortresses in order to prepare for war again. The Thaqif tribe were the same people who marched towards Makkah with Hawazin tribe (and others) in order to kill Muslims, and when they were confronted with the Muslim army, they retreated from the Battle of Hunayn to Ta’if, in order to get strong again and attack the Muslims. They were pursued as a consequence of that they would have attacked the Muslims again if they weren’t dealt with, 1400 years ago.
If these enemies asked to be forgiven for what they did, the Prophet (p) most probably would have forgiven them. But they didn’t do that, instead they retreated to Ta’if area to mobilize, attack and use this place for military purposes against the Muslims.
“When the fugitives of Thaqif came to al-Ta’if they shut the gates of the city and made preparations for war. …” 
Kitab futuh al-Buldan:
“THE PROPHET LAYS SIEGE TO AT-TA’IF
When the Hawazin were defeated in the battle of Hunain, and Duraid Ibn As-Simmah was slain, the surviving remnant came to Awtas. The Prophet sent them Abu Amir al-Ash’ari who was put to death. Then Abu Musa Abdallah Ibn-Kais al-Ash’ari took the command and the Moslems advanced on Awtas. Seeing that, the chief of the Hawazin at that time, Malik Ibn-Auf Ibn-Sa’d of Banu-Duhman Ibn-Nasr Ibn-Mu’awiyah Ibn-Bakr Ibn Hawazin, fled to at-Ta’if, whose people he found ready for the siege with their fortress repaired and the provisions gathered therein. Here he settled. The Prophet led the Moslems until they got to at-Ta’if. Thakif hurled stones and arrows on the Moslems, and the Prophet set a ballista on the fortress. The Muslims had a mantelet made of cows skins on which Thakif threw hot iron bars and burnt it, killing the Moslems underneath. The siege of at-Ta’if by the Prophet lasted for fifteen days, the invasion having begun in Shawwal, in the year 8.” 
“When God’s Apostle besieged Taif and could not conquer its people, he said, “We will return (to Medina) If God wills.” That distressed the Companions (of the Prophet and they said, “Shall we go away without conquering it (i.e. the Fort of Taif)?” Once the Prophet said, “Let us return.” Then the Prophet said (to them), “Fight tomorrow.” They fought and (many of them) got wounded, whereupon the Prophet said, “We will return (to Medina) tomorrow if God wills. …” (Sahih Bukhari, volume 5, Book 59, Number 615)
“The Prophet besieged the people of Ta’if, but he did not conquer it. He said, “Tomorrow, if God will, we will return home. On this the Muslims said, “Then we return without conquering it?” He said, ‘Then carry on fighting tomorrow.” The next day many of them were injured. The Prophet said, “If God will, we will return home tomorrow. …” (Sahih Bukhari, volume 9, Book 93, Number 572)
Ta’if Campaign (Siege)
Ta’if Campaign is in fact an extension of Hunain Ghazwah; that is because the majority of the defeated troops of Hawazin and Thaqif went into Ta’if with the general commander — Malik bin ‘Awf An-Nasri — and fortified themselves within it. So upon finishing with Hunain Invasion, he gathered the booty at Al-Ji‘ranah in the very month (i.e. Shawwal) and in the eighth year A.H.
A vanguard battalion of a thousand men led by Khalid bin Al-Waleed marched towards At-Ta’if. Whereas the Messenger of Allah [pbuh] proceeded passing through Nakhlah Al-Yamaniyah, Qarn Al-Manazil and through Laiyah. At Laiyah there was a castle that belonged to Malik bin ‘Awf, so the Messenger of Allah [pbuh] gave orders to have it destroyed. He resumed his march till he got to Ta’if. There he dismounted, camped near its castle and laid siege to the castle inhabitants; but not for long. How long the siege continued, is still a matter of disagreement. It however stands between 10-20 days. [Sahih Muslim, narrated by Anas [AWS]; Fath Al-Bari 8/45]
A lot of arrow-shooting and rock-hurling occurred during the siege. For as soon as the Muslims laid siege round the castle, its people started shooting arrows against them. The arrows were so intense and fierce that they looked as if they had been locusts on the move. A number of Muslims were wounded and twelve were killed. To be far from the arrow-range, the Muslims had to ascend to a higher location and camped on — i.e. to what is now called At-Ta’if Mosque. The Prophet [pbuh] set up a mangonel and shelled the castle. Eventually a gap was made in the castle wall, through which a number of Muslims managed to pass into the castle, sheltered by a wooden tank, with the purpose of setting fire into it. Anyway, the enemy poured down molten hot iron on them. Affected by this the Muslims stepped out of the tank and were again exposed to arrow shooting and consequently some of them were killed.
To force the enemy to surrender, the Prophet [pbuh] tended to a war policy of burning and cutting the enemy’s crops. His order was to cut their vineyards and burn them. Seeing that the Muslims started rapidly cutting and burning their vines, they implored the Prophet [pbuh] to stop and have mercy on them for the sake of Allah and out of kinship motives. So the Prophet agreed. When the caller of the Messenger of Allah [pbuh] called out unto people saying “He whosoever descends and steps out of the castle is free.” Twenty-three men came out. [Sahih Al-Bukhari 2/620] One of them was Abu Bakrah who tied himself to a wall and let himself down by means of a small wheel, that would normally be used for drawing up water from a well. The way he let himself down made the Prophet nickname him “Abu Bakrah”, i.e. the man with the wheel. The Messenger of Allah set them all free and entrusted each one of them to a Muslim to care about their living affairs, which was too hard for the castle folks people to bear.
Seeing that the siege lasted too long and that the castle was immune and could stand any siege (for they had already stored a supply that suffices for over a year) and that the Muslims were suffering — day by day — from arrow-shots and heated iron hooks, the Messenger of Allah [pbuh] consulted Nawfal bin Mu‘awiyah Ad-Daili about that. He said: “They are like a fox hiding inside its burrow. If you stoodfast at it you would catch it, but if you parted with it, no harm would afflict you.” The Messenger of Allah [pbuh] decided to lift the siege and depart. ‘Umar bin Al-Khattab, who was ordered by the Prophet to notify people, said to them “If Allah will, we are leaving the castle and going back tomorrow.” As it was too hard for the Muslims to go back and leave the castle unconquered they complained saying, “Should we go away while the castle is still unopened?” His reply was: “Then, start fighting in the morning.” In the morning they fought and were wounded. So when he repeated this statement: “If Allah will, we are leaving the castle and going back tomorrow”, they were pleased and carried out the order submissively and started moving, which made the Messenger of Allah [pbuh] laugh. As soon as they mounted and started moving the Messenger [pbuh] said: “Say! Here we are returning, repenting, worshipping (Allah) and to our Lord we offer praise.” When the Messenger of Allah was asked to invoke Allah against Thaqif, he said:
“O Allah, guide Thaqif and bring them to us as Muslims.” 
Shaykh Allama Shibli Numani:
“SIEGE OF TA’IF
The remnants of the force vanquished at Hunain sought refuge at Ta’if and prepared to make a stand again. Ta’if was a safe place, so-called because it had a well running round the city. The Thaqif tribe settled there was known for its chivalry and enjoyed a distinguished status almost at par with that of the Quraish. …” 
Don’t forget to follow Discover The Truth on Facebook and Twitter. PLEASE help spread the word by sharing our articles on your favourite social networks. Thank You!
 Ibn Ishaq’s Sirat Rasul Allah – The Life of Muhammad [Translated: A. Guillaume], page 587
 The origins of the Islamic state, being a translation from the Arabic, accompanied with annotations, geographic and historic notes of the Kitab futuh al-buldan of al-Imam abu-l Abbas Ahmad ibn-Jabir al-Baladhuri, [Published 1916], volume 1, page 85
 Sealed Nectar (‘Ar-Raheeq Al-Makhtum’), By Safiur-Rahman Al-Mubarakpuri, page 218
 Sirat -un- Nabi By Shaykh Allama Shibli Numani, volume 2, page 215