Al-Muhajir b. Qunfudh said that he came upon the Prophet when he was passing water and saluted him, but he did not respond to the salutation till he had performed ablution. He then made his excuse to him saying, “I dislike mentioning God's name except when I am in a state of purity.”
Abu Dawud transmitted it. Nasa’i transmitted it up to “till he had performed ablution” and said, “then when he had performed ablution he responded to it.”
Shu'ba said that when Ibn ‘Abbas washed because of seminal defilement he emptied water seven times from his right hand over his left hand, then washed his private parts. Once he forgot how often he had emptied it, so he asked Shu'ba, but he replied that he did not know, so he said, “You should be ashamed of yourself. What prevents you from knowing?” Then he would perform his ablution for prayer, then pour water over his body and say, “Thus was God’s messenger accustomed to purify himself.”
I accompanied Ibn ‘Umar who wanted to relieve himself. After doing so, in the course of his talk that day he said that a man going along a street met God’s messenger when he came out of the privy, or had passed water, and saluted him without receiving any response. Then when the man was almost going out of sight in the street God’s messenger struck his hands on a wall, wiped his face with them, struck once more and wiped his forearms, then responded to the man’s salutation, saying, “The only thing which prevented me from responding to your salutation was that I was not in a state of purity.”