Musnad Ahmad 668, 669
It was narrated that `Ali bin Abi Talib (رضي الله عنه) said:
Whilst we were praying with the Messenger of Allah (ﷺ), he left whilst we were standing there, then he came back with his head dripping and led us in prayer. Then he said: “I remembered that I was junub when I got up to pray and had not done ghusl. Whoever hears a sound in his stomach or is in the state I was in, let him go and relieve himself or do ghusl, then come back to his prayer.` 


It was narrated from `Abdullah bin Zurair from `Ali (رضي الله عنه) and he narrated a similar report.
حَدَّثَنَا حَسَنُ بْنُ مُوسَى، حَدَّثَنَا ابْنُ لَهِيعَةَ، حَدَّثَنَا الْحَارِثُ بْنُ يَزِيدَ، عَنْ عَبْدِ اللَّهِ بْنِ زُرَيْرٍ الْغَافِقِيِّ، عَنْ عَلِيِّ بْنِ أَبِي طَالِبٍ، رَضِيَ اللَّهُ عَنْهُ قَالَ بَيْنَمَا نَحْنُ مَعَ رَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ نُصَلِّي إِذْ انْصَرَفَ وَنَحْنُ قِيَامٌ ثُمَّ أَقْبَلَ وَرَأْسُهُ يَقْطُرُ فَصَلَّى لَنَا الصَّلَاةَ ثُمَّ قَالَ إِنِّي ذَكَرْتُ أَنِّي كُنْتُ جُنُبًا حِينَ قُمْتُ إِلَى الصَّلَاةِ لَمْ أَغْتَسِلْ فَمَنْ وَجَدَ مِنْكُمْ فِي بَطْنِهِ رِزًّا أَوْ كَانَ عَلَى مِثْلِ مَا كُنْتُ عَلَيْهِ فَلْيَنْصَرِفْ حَتَّى يَفْرُغَ مِنْ حَاجَتِهِ أَوْ غُسْلِهِ ثُمَّ يَعُودُ إِلَى صَلَاتِهِ
حَدَّثَنَا يَحْيَى بْنُ إِسْحَاقَ حَدَّثَنَا ابْنُ لَهِيعَةَ عَنِ الْحَارِثِ بْنِ يَزِيدَ عَنْ عَبْدِ اللَّهِ بْنِ زُرَيْرٍ عَنْ عَلِيٍّ رَضِيَ اللَّهُ عَنْهُ فَذَكَرَ مِثْلَهُ‏.‏