Sayyiduna Anas bin Malik (may Allah be pleased with him) said: We were sitting in the mosque with the Prophet (peace and blessings be upon him) when suddenly a Bedouin came and began to urinate in the mosque. The Companions (may Allah be pleased with them) began to stop him, but he (peace and blessings be upon him) said: "Leave him." The Companions left him until he had finished urinating. He (peace and blessings be upon him) said: "These are mosques; urine and filth are not fitting in them. They are only for the remembrance of Allah, prayer and the recitation of the Qur'an," or as the Prophet (peace and blessings be upon him) said. Then he (peace and blessings be upon him) ordered a man, who brought a bucket of water, and he (peace and blessings be upon him) poured it over the urine.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 4142