Sahih Muslim , Hadith 1962

Anas (b. Malik) reported Allah's Messenger having said on the day of Nahr (Sacrifice): He who slaughtered (the animal as a sacrifice) before the ('Id) prayer. should repeat it (i. e. offer another animal). Thereupon a person stood up and said: Messenger of Allah, that is the day when meat is much desired, and he also made a mention of the need of his neighbour, and perhaps Allah's Messenger attested it. He (the person who had sacrificed the animal before the 'Id prayer) said: I have a goat of less than one year of age with me and I like it more than two fleshy goats; should I offer it as a sacrifice? He permitted him to do so. He (the narrator) said: I do not know whether this permission was granted to anyone else besides him or not. Allah's Messenger then turned towards two rams. and he slaughtered them, and the people' came to the goats and got them distributed amongst themselves (for offering them as sacrifice).

وَحَدَّثَنِي يَحْيَى بْنُ أَيُّوبَ، وَعَمْرٌو النَّاقِدُ، وَزُهَيْرُ بْنُ حَرْبٍ، جَمِيعًا عَنِ ابْنِ عُلَيَّةَ، - وَاللَّفْظُ لِعَمْرٍو - قَالَ حَدَّثَنَا إِسْمَاعِيلُ بْنُ إِبْرَاهِيمَ، عَنْ أَيُّوبَ، عَنْ مُحَمَّدٍ، عَنْ أَنَسٍ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم يَوْمَ النَّحْرِ ‏ "‏ مَنْ كَانَ ذَبَحَ قَبْلَ الصَّلاَةِ فَلْيُعِدْ ‏" ‏ ‏.‏ فَقَامَ رَجُلٌ فَقَالَ يَا رَسُولَ اللَّهِ هَذَا يَوْمٌ يُشْتَهَى فِيهِ اللَّحْمُ ‏.‏ وَذَكَرَ هَنَةً مِنْ جِيرَانِهِ كَأَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم صَدَّقَهُ قَالَ وَعِنْدِي جَذَعَةٌ هِيَ أَحَبُّ إِلَىَّ مِنْ شَاتَىْ لَحْمٍ أَفَأَذْبَحُهَا قَالَ فَرَخَّصَ لَهُ فَقَالَ لاَ أَدْرِي أَبَلَغَتْ رُخْصَتُهُ مَنْ سِوَاهُ أَمْ لاَ قَالَ وَانْكَفَأَ رَسُولُ اللَّهِ صلى الله عليه وسلم إِلَى كَبْشَيْنِ فَذَبَحَهُمَا فَقَامَ النَّاسُ إِلَى غُنَيْمَةٍ فَتَوَزَّعُوهَا ‏.‏ أَوْ قَالَ فَتَجَزَّعُوهَا ‏.‏

sunnah.com

Anas b. Malik reported that Allah's Messenger offered the 'Id prayer and then delivered the sermon giving the command: He who slaughtered the animal before prayer should slaughter (another animal as a sacrifice). The rest of the hadith is the same.

حَدَّثَنَا مُحَمَّدُ بْنُ عُبَيْدٍ الْغُبَرِيُّ، حَدَّثَنَا حَمَّادُ بْنُ زَيْدٍ، حَدَّثَنَا أَيُّوبُ، وَهِشَامٌ، عَنْ مُحَمَّدٍ، عَنْ أَنَسِ بْنِ مَالِكٍ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم صَلَّى ثُمَّ خَطَبَ فَأَمَرَ مَنْ كَانَ ذَبَحَ قَبْلَ الصَّلاَةِ أَنْ يُعِيدَ ذِبْحًا ثُمَّ ذَكَرَ بِمِثْلِ حَدِيثِ ابْنِ عُلَيَّةَ ‏.‏

sunnah.com

Anas b. Malik reported: Allah's Messenger addressed us on the day of 'Id al-Adha. He smelt the odour of flesh and he prohibited thern from slaughtering (the animals before the 'Id prayer), saying: He who slaughtered the animals (before the 'Id prayer) should do that again (as it is not valid as a sacrifice).

وَحَدَّثَنِي زِيَادُ بْنُ يَحْيَى الْحَسَّانِيُّ، حَدَّثَنَا حَاتِمٌ، - يَعْنِي ابْنَ وَرْدَانَ - حَدَّثَنَا أَيُّوبُ، عَنْ مُحَمَّدِ بْنِ سِيرِينَ، عَنْ أَنَسِ بْنِ مَالِكٍ، قَالَ خَطَبَنَا رَسُولُ اللَّهِ صلى الله عليه وسلم يَوْمَ أَضْحًى - قَالَ - فَوَجَدَ رِيحَ لَحْمٍ فَنَهَاهُمْ أَنْ يَذْبَحُوا قَالَ ‏ "‏ مَنْ كَانَ ضَحَّى فَلْيُعِدْ ‏" ‏ ‏.‏ ثُمَّ ذَكَرَ بِمِثْلِ حَدِيثِهِمَا ‏.‏

sunnah.com