BAYHAQI 3376:
from Abū Hurayrah —
[Machine] The Messenger of Allah ﷺ said, "If one of you is in prayer and feels movement in his behind, whether intentional or unintentional, he should not leave his prayer until he hears a sound or finds a smell. This is evidence that he should leave if he hears a sound or finds a smell, there is no difference between whether it was deliberate, a mistake, or a previously passed wind. Allah knows best."
البيهقي ٣٣٧٦:
عن ابو هريره —
أَنَّ رَسُولَ اللهِ ﷺ قَالَ إِذَا كَانَ أَحَدُكُمْ فِي الصَّلَاةِ فَوَجَدَ حَرَكَةً فِي دُبُرِهِ أَحْدَثَ أَوْ لَمْ يُحَدِثْ فَأُشْكِلَ عَلَيْهِ فَلَا يَنْصَرِفْ حَتَّى يَسْمَعَ صَوْتًا أَوْ يَجِدَ رِيحًا وَفِي هَذَا دَلِيلٌ عَلَى أَنَّهُ يَنْصَرِفُ إِذَا سَمِعَ صَوْتًا أَوْ وَجَدَ رِيحًا لَا فَرْقَ فِيهِ بَيْنَ عَمْدِهِ وَسَهْوِهِ وَسَبْقِهِ وَاللهُ أَعْلَمُ
hadithunlocked.com