All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
First of all, it should be mentioned that touching the private parts does not necessarily mean that one’s hands have become impure, so it is not an obligation to wash the hands just because of this. However, not washing the hands after touching one’s private parts is considered contrary to the fact that a Muslim should be clean and avoid uncleanness. Additionally, even though it can not be ruled that one’s hands become impure by touching his private parts, it is probable that one may touch the impurity, sweat or what is considered as dirt when he touches his private parts. That is why it is reported in the Sunnah that one should wash his hands when waking up from sleep and before putting them in the water (i.e. into the vessel containing the water prepared) for ablution as per the Hadeeth “Whoever wakes up from his sleep should wash his hands before putting them in the water for ablution, because nobody knows where his hands were during sleep.” [Al-Bukhari and Muslim]
The scholars mentioned the wisdom behind this that the sleeping person may place his hands on an impure matter on his body or touch a pustule, a louse, or dirt. The scholars also concluded from this Hadeeth that it is recommended to cleanse one’s body from the suspected impurity. Therefore, whoever touches his private parts with his hand; it is better for him to wash his hand even if he is not sure that it became impure.
As regards not shaking hands with a person whom one knows that he has touched his private parts with his hands and did not wash them, then first of all, we would say that shaking hands is not an obligation but just desirable, and principally, a person is not sinful for not doing what is desirable. Also, shaking hands with a person whose hand is impure is not forbidden, let alone shaking hands with someone whom one does not know whether or not his hands became impure.
Therefore, we do not see any harm in not shaking hands in the situation mentioned above unless that person stretched out his hands to you (to shake hands with him) and it is known that if you do not shake hands with him, this will lead to a disadvantage, like dissension or him deserting you [for that reason], and the like, then in this case, you should avoid this disadvantage in order to attract his heart. For more benefit, please refer to Fatwa 84093.
Allaah knows best.