When the Quraysh defied the Prophet ﷺ, he prayed against them, asking Allah to afflict them with years of famine like the years of Yusuf. So a drought and severe hardship struck them until they ate bones. A man would look up at the sky and see something like smoke between him and it because of the intensity of his hunger. Then Allah Almighty revealed, "So watch for the Day when the sky will bring a visible smoke covering the people. This is a painful torment" [Dukhan 44:10–11].The Messenger of Allah ﷺ was approached, and it was said, "Messenger of Allah, pray to Allah for rain on behalf of Mudar, for they have perished."He replied, "For Mudar? You are indeed bold."Then he prayed for rain, and they were given rain. So the verse was revealed, "Indeed, you will return". When ease returned to them, they reverted to their former state once prosperity reached them, so Allah revealed, "The Day We will strike with the greatest assault, indeed, We will take retribution". He said, this refers to the day of Badr.
إن قريشا لما استعصوا على النبي ﷺ دعا عليهم بسنين كسني يوسف، فأصابهم قحط وجهد حتى أكلوا العظام، فجعل الرجل ينظر إلى السماء فيرى ما بينه وبينها كهيئة الدخان من الجهد، فأنزل الله تعالى: {فارتقب يوم تأتي السماء بدخان مبين يغشى الناس هذا عذاب أليم} [سورة الدخان: ١٠-١١] قال: فأتي رسول الله ﷺ فقيل: يا رسول الله! استسق الله لمضر، فإنها قد هلكت. قال: لمضر؟ إنك لجريء. فاستسقى فسقوا. فنزلت: {إنكم عائدون} فلما أصابتهم الرفاهية عادوا إلى حالهم حين أصابتهم الرفاهية، فأنزل الله عز وجل: {يوم نبطش البطشة الكبرى إنا منتقمون} قال: يعني يوم بدر.
Bukhari narrated it in the tafsir (4821), and Muslim in the Attributes of the Hypocrites (2798/40), both through Abu Muawiya, from Amash, from Muslim bin Subayh, from Masruq, from Ibn Masud, who related it. The wording given here is Bukhari's, and Muslim's wording is similar with a slight difference.In the other sahih narrations, the one who asked the Prophet ﷺ to lift the hardship was Abu Sufyan.As for what appears in Sahih Bukhari (1020) under the chapter mentioned, in Bukhari's words, "and Asbat added, from Mansur, 'So the Messenger of Allah ﷺ prayed, and they were given rain, and it covered them for seven days, and the people complained of the excess of rain, so he said, "O Allah, around us and not upon us," and the cloud parted from over his head, and the people around them were given rain'" - this is part of the hadith of Anas bin Malik mentioned in the chapter on praying for rain during the Friday sermon without facing the qibla, and this incident took place in Madinah. It appears that this Asbat is Asbat bin Nasr, for he has been described as one who made many mistakes, and he is, besides that, a narrator of strange reports.Shaykh Wali Allah Dahlawi points to this in his treatise Sharh Tarajim Abwab Sahih Bukhari (p. 107), commenting on the hadith of Abdullah bin Masud which Bukhari mentioned under this chapter, "It seems that a confusion and mixing occurred in this chain."For the story of the drought of Quraysh took place before the Prophet's ﷺ arrival in Madinah, since it is not known that Abu Sufyan came to Madinah before Badr, and this is indicated by Ibn Umar's quoting of Abu Talib's poem: