They came to the Prophet ﷺ in Makkah and said, "Messenger of Allah, we were honored when we were polytheists, but when we believed, we became humiliated."He replied, "I have been commanded to pardon, so do not fight."When Allah moved us to Madinah, He commanded us to fight, but they held back. So Allah revealed, "Have you not seen those who were told to restrain their hands and establish prayer" [Nisa 4:77].
أخبرنا محمد بن علي بن الحسن بن شقيق قال أنبأنا أبي قال أنبأنا الحسين بن واقد عن عمرو بن دينار عن عكرمة عن ابن عباس أن
له أتوا النبي ﷺ بمكة فقالوا يا رسول الله إنا كنا في عز ونحن مشركون فلما آمنا صرنا أذلة فقال إني أمرت بالعفو فلا تقاتلوا فلما حولنا الله إلى المدينة أمرنا بالقتال فكفوا فأنزل الله عز وجل {ألم تر إلى الذين قيل لهم كفوا أيديكم وأقيموا الصلاة}
Sourcing, sahih chain. Tabari transmitted it in his Tafsir, 5/108, from Muhammad bin Ali bin Hasan through the same chain. It is also in al-Kubra, no. 4293. Hakim graded it sahih, 2/66, 307, and Dhahabi agreed with him.