Mishkat al-Masabih 121
وَعَنِ ابْنِ عَبَّاسٍ عَنِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ: أَخذ الله الْمِيثَاق من ظهر آدم بنعمان يَعْنِي عَرَفَة فَأخْرج من صلبه كل ذُرِّيَّة ذَرَاهَا فَنَثَرَهُمْ بَيْنَ يَدَيْهِ كَالذَّرِّ ثُمَّ كَلَّمَهُمْ قِبَلًا قَالَ: (أَلَسْتُ بِرَبِّكُمْ قَالُوا بَلَى شَهِدْنَا أَنْ تَقُولُوا يَوْمَ الْقِيَامَةِ إِنَّا كُنَّا عَنْ هَذَا غافلين أَوْ تَقُولُوا إِنَّمَا أَشْرَكَ آبَاؤُنَا مِنْ قَبْلُ وَكُنَّا ذُرِّيَّةً مِنْ بَعْدِهِمْ أَفَتُهْلِكُنَا بِمَا فَعَلَ المبطلون) رَوَاهُ أَحْمد
From Ibn ʿAbbas, from the Prophet ﷺ, who said: "Allah took the covenant from the back of Adam at Naʿman, meaning ʿArafah. He brought out from his loins all the offspring He would create and scattered them before Him like tiny ants, then spoke to them face to face. He said: 'Am I not your Lord?' They said: 'Yes, we testify.' [This] lest you say on the Day of Resurrection: 'We were unaware of this,' or lest you say: 'Our fathers associated partners [with Allah] before, and we were offspring after them; will You then destroy us for what the falsifiers did?'" Reported by Ahmad.