If one enters the restroom, one must wash one’s hands upon exiting, even if one did not facilities. Hand-washing in this regard refers to washing one’s hand under the faucet; it is proper to do this three times. However, washing one’s hands with a vessel is not necessary.
The reason one must wash one’s hands upon emerging from the restroom is because an evil spirit rests there and when one enters, this evil spirit rests on one’s hands. In order to remove this spirit from one’s hands, one must wash one’s hands with water (see Reponsa Yabia Omer, Volume 3, Chapter 1 and Yechave Da’at, Volume 3, Chapter 1).
Indeed, we once witnessed that Maran zt”l had come to visit the new house of a lonely woman in order to gladden her. She gave Maran zt”l a guided tour of all of the rooms in the house and he followed her into every room. However, when she showed him the bathroom, Maran zt”l did not wish to enter so as not to become obligated to wash his hands and remain there longer than necessary.
It happens sometimes that one will stick one’s hand into the bathroom to grab a tissue and the like. The question becomes: Can the evil spirit rest on only one hand or shall we say that even in this case, one must still wash both hands?
Hagaon Maharsham (in his Da’at Torah, Chapter 4) writes that if one sticks one’s hand into the bathroom, one need not wash even the hand that was stuck in, for the evil spirit does not rest on one’s hands in this manner. He proceeds to support his opinion with a proof. Nevertheless, the Yalkut Yosef (Chapter 3, page 459) rebuffs this proof.
Hagaon Rabbeinu Chaim Palagi zt”l writes in his Sefer Ruach Chaim (Chapter 3) that if one sticks one’s hand into the restroom, one must wash both hands, for the evil spirit rests on the hand one stuck in to the restroom and this, in turn, causes it to rest on both hands. Several Poskim concur and write that this situation is not analogous to that of when one touches filthy with one hand in which case one must only wash that hand, for there, there is no concern of an evil spirit and the hand-washing is meant for cleanliness and hygienic purposes. On the other hand, as we have explained, entering the restroom entails an element of retaining an evil spirit on one’s hands.
Nevertheless, Maran Rabbeinu Ovadia Yosef zt”l writes (in his Responsa Yabia Omer, Volume 9, Chapter 108, Section 15) that it seems that if one stuck only one hand into the bathroom, it is sufficient to wash only that hand, for the evil spirit does not rest on both hands in this way. He proceeds to support this with several proofs. However, if one does wash both hands, this is especially admirable.
Summary: If one enters the restroom, one must wash one’s hands upon exiting. If one sticks one’s hand into the restroom, one must wash at least that hand.