Prophet (P.b.u.h) decided to focus on the expansion of Islam.
Therefore he travelled to the valley of Taif along with his adopted son Zayd bin Haris to spread Islam.
His message was not at all welcomed in fact young boys hurled stones at him until he bled.
Eventually, the prophet along with Zayd took refuge in a nearby orchard and when an angel asked about punishing the people prophet (P.b.u.h) refused recognizing their influence and infact prayed for them:
“Why should I pray for the destruction of these people? I hope that their posterity will certainly be among the believers in one Allah”
In 9 AH the whole of Taif embraced Islam
After the visit to taif, he realized that he needed another place to preach Islam as it was certainly not acceptable to the people of Taif.