Mishkat al-Masabih 492
Anas said:
While we were in the mosque with God’s messenger a desert Arab came and began to pass water in the mosque. The companions of God's messenger said, “Stop! Stop!” but God’s messenger said,
“Don’t interrupt him; leave him alone.” They left him alone, and when he had finished God’s messenger called him and said to him, “These mosques are not suitable places for urine and filth, but are only for remembrance of God, prayer and recitation of the Qur’an,” or however God’s messenger expressed it.* Anas said that he then grave orders to one of the people who brought a bucket and poured water over it.
*Indicating that the transmitter is not sure of the exact words.

(Bukhari and Muslim.)
وَعَن أنس قَالَ: بَيْنَمَا نَحْنُ فِي الْمَسْجِدِ مَعَ رَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ إِذْ جَاءَ أَعْرَابِيٌّ فَقَامَ يَبُولُ فِي الْمَسْجِدِ فَقَالَ أَصْحَابُ رَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ مَهْ مَه قَالَ فَقَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «لَا تَزْرِمُوهُ دَعُوهُ» فَتَرَكُوهُ حَتَّى بَالَ ثُمَّ إِنَّ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ دَعَاهُ فَقَالَ لَهُ: «إِنَّ هَذِهِ الْمَسَاجِدَ لَا تصلح لشَيْء من هَذَا الْبَوْل وَلَا القذر إِنَّمَا هِيَ لذكر الله عز وَجل وَالصَّلَاةِ وَقِرَاءَةِ الْقُرْآنِ» أَوْ كَمَا قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ فَأمر رَجُلًا مِنَ الْقَوْمِ فَجَاءَ بِدَلْوٍ مِنْ مَاءٍ فسنه عَلَيْهِ