كتاب الحج
15  
The Book of Pilgrimage
(57)
Chapter: It is permissible to offer the sacrifice before stoning the Jamrah, or to shave before offering the sacrifice or stoning the Jamrah, or to perform Tawaf before any of them
(57)
باب مَنْ حَلَقَ قَبْلَ النَّحْرِ أَوْ نَحَرَ قَبْلَ الرَّمْىِ ‏‏
Sahih Muslim 1306 b

'Abdullah b. 'Amr b. al-'As (Allah be pleased with them) reported:

Allah's Messenger (ﷺ) stopped while riding his camel and the people began to ask him. One of the inquirers said: Messenger of Allah, I did not know that pebbles should be thrown before sacrificing the animal, and by mistake I sacrificed the animal before throwing pebbles, whereupon Allah's Messenger (ﷺ) said: (Now) throw pebbles and there is no harm in it. Then another (person) came saying: I did not know that the animal was to be sacrificed before shaving, but I got myself shaved before sacrificing the animal, whereupon he (the Holy Prophet) said: Sacrifice the animal (now) and there is no harm in it. He (the narrator) said: I did not hear that anything was asked on that day (shout a matter) which a person forgot and could not observe the sequence or anything like it either due to forgetfulness or ignorance, but Allah's Messenger (ﷺ) said (about that): Do it; there is no harm in it.
وَحَدَّثَنِي حَرْمَلَةُ بْنُ يَحْيَى، أَخْبَرَنَا ابْنُ وَهْبٍ، أَخْبَرَنِي يُونُسُ، عَنِ ابْنِ شِهَابٍ، حَدَّثَنِي عِيسَى بْنُ طَلْحَةَ التَّيْمِيُّ، أَنَّهُ سَمِعَ عَبْدَ اللَّهِ بْنَ عَمْرِو بْنِ الْعَاصِ، يَقُولُ وَقَفَ رَسُولُ اللَّهِ صلى الله عليه وسلم عَلَى رَاحِلَتِهِ فَطَفِقَ نَاسٌ يَسْأَلُونَهُ فَيَقُولُ الْقَائِلُ مِنْهُمْ يَا رَسُولَ اللَّهِ إِنِّي لَمْ أَكُنْ أَشْعُرُ أَنَّ الرَّمْىَ قَبْلَ النَّحْرِ فَنَحَرْتُ قَبْلَ الرَّمْىِ ‏.‏ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ فَارْمِ وَلاَ حَرَجَ ‏"‏ ‏.‏ قَالَ وَطَفِقَ آخَرُ يَقُولُ إِنِّي لَمْ أَشْعُرْ أَنَّ النَّحْرَ قَبْلَ الْحَلْقِ فَحَلَقْتُ قَبْلَ أَنْ أَنْحَرَ ‏.‏ فَيَقُولُ ‏"‏ انْحَرْ وَلاَ حَرَجَ ‏"‏ ‏.‏ قَالَ فَمَا سَمِعْتُهُ يُسْأَلُ يَوْمَئِذٍ عَنْ أَمْرٍ مِمَّا يَنْسَى الْمَرْءُ وَيَجْهَلُ مِنْ تَقْدِيمِ بَعْضِ الأُمُورِ قَبْلَ بَعْضٍ وَأَشْبَاهِهَا إِلاَّ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ افْعَلُوا ذَلِكَ وَلاَ حَرَجَ ‏"‏ ‏.‏
Reference : Sahih Muslim 1306b
In-book reference : Book 15, Hadith 361
USC-MSA web (English) reference : Book 7, Hadith 2996
  (deprecated numbering scheme)