one who enters a restroom – even if he does not perform his bodily functions – must wash his hands before praying, reciting a Beracha, or studying Torah. A certain "Ru'ach Ra'a," or "evil spirit," descends upon a person when he enters the restroom, and he must therefore wash his hands before engaging in Torah study or prayer. No Beracha, however, is recited over this hand-washing.
Must one wash his hands if he only extended his hands in the restroom, while standing outside? It occasionally happens that a person has to retrieve an item from the restroom, and does so by standing outside and reaching in to take the given object. Does this require him to wash his hands?
Rav Chayim Palachi (Rabbi of Izmir, Turkey, 19th century) discusses this question in his work "Lev Chayim," (Helek 2:2) where he writes that one must, indeed, wash his hands after placing his hands in the restroom. Even if the rest of his body remained outside the restroom, he must nevertheless wash his hands after placing them in the restroom.
The Ben Ish Chai (Rabbi Yosef Chayim of Baghdad, 1833-1909), in his work of responsa "Torah Lishma," (Siman 23) clarifies that if one extends only one hand in the restroom, then he is required to wash only that hand; he does not have to wash both hands, since only one hand was exposed to the impurity of the restroom. Nevertheless, Chacham Bentzion Abba Shaul (Jerusalem, 1924-1998) writes his work "Or Le'tzion" (Vol. 2, 1:13) that even in such a case one should preferably wash both hands. He apparently understood that the impurity that descends upon the individual's hand spreads even to the second hand, and therefore one should wash both hands, even if only one hand had been in the restroom. He adds that even if a person placed just one finger in the restroom, he should wash both hands.
Summary: If a person walks into a restroom, he must wash his hands – though without a Beracha – before studying Torah, praying or reciting a Beracha. This applies even if an individual merely extended his hands into a restroom. If a person extended only one hand into the restroom, then he must wash that hand, and should preferably wash even the second hand, as well.