Hand shaking is a means of formal communication between two parties that signify friendship, endearment, and business relations. Shaking the hands of the opposite gender poses the question of whether doing so transgresses the prohibition against showing affectionate touch towards the opposite gender. The following is the ruling of the Poskim on this matter:
It is Biblically forbidden to shake hands with the opposite gender if doing so serves as an act of affection [Derech Chiba] or gives the person pleasure. Based on this, the Poskim rule that it is forbidden to shake hands with the opposite gender, even when it is done out of a mere sign of respect and business norms without any intent of affection.
One is wearing a glove: The prohibition against hand shaking with the opposite gender applies even if the other person is wearing a glove.
The person of the opposite gender already stuck out their hand: The prohibition against hand shaking with the opposite gender applies even if the other person has already stuck out their hand to be shaken, even if this may cause one to be ridiculed. [This follows the ruling in the first chapter of Shulchan Aruch “One should be as bold as a leopard and not allow himself to get intimidated or embarrassed by those who scoff at his service of G-d.” Nevertheless, some are lenient in this matter in a situation that can cause the other person to be offended. Practically, the accepted ruling today amongst all Chareidi Jewry is to prohibit handshaking in all situations, as ruled and practiced by the leading Poskim mentioned above, and so is certainly the Chabad practice.]
Avoiding embarrassing the person:
Although it is prohibited to shake hands with the opposite gender, as brought from the Poskim above, nonetheless care must be taken not to offend or hurt the other person whose hand is not being shaken, or whose outstretched hand remains suspended in the air without a return gesture. A polite explanation of the issue or other act of acceptable reason of avoidance is to be expressed in such situations. The following should be done:
Stories associated with hand shaking of famous personalities:
The Munkatcher Rebbe and the Queen of Holand: The Queen Wilhelmina of Holand once cam to meet the previous Munkatcher Rebbe [Minhcas Elazar] to receive a blessing due to her being childless. Upon her outstretching her hand to shake the Rebbe’s hand the Rebbe replied that it is unbefitting for a commoner to touch the hand of her majesty. The queen was very impressed and it made a positive impression upon her. The queen subsequently gave birth to a daughter.
The Ponovitcher Rav with a wealthy patron: A wealthy female patron of the Ponovitch Yeshiva was once sitting next to the Ponovitcher Rav and upon her getting up to leave she cordially stuck out her hand towards the Rav in order to shake his hand prior to parting. The Rav, motioned to her that she should continue to remain with him as he still desires her company, and hence she retreated her outstretched hand and sat back down. After some more time passed, she again got up to leave and gave out her hand to be shaken and again the Rav motioned her that he stiull desires top enjoy her company. By the third time she simply got up and left, not wanting to be embarrassed to refuse the Rav’s request for her to continue to sit near him.
Rav Ovadia Yosef and Gold Meir: When Harav Ovadia Yosef was serving as the Chief Rabbi of Israel, he received the Israel prize award. During the ceremony he was summoned to the stage in which sat many of the leading Israeli dignitaries, including the minister of education, and the prime minister of that time, Golda Meir. Rav Ovadia cordially shook the hands of the minister of education upon receiving the award and was then given an outstretched hand by the Prime Minister, Golda Meir, who also desired to shake his hand to congratulate him. The cameras were all focused on this event which was broadcasted live to all Israeli media. The Rav cordially shook his head as a notion of engagement and respect towards her gestor, although he did not return the hand shake.
Rav Mordechai Eliyahu and the queen of England: Ha-Rav Mordechai Eliyahu once met with the Queen of England and she put out her hand. There were cameras from all around the world, but he stood still like a soldier and did not shake it. That evening Rav Eliyahu received a letter from the person responsible for royal protocol apologizing for the incident. They checked the books of protocol for the British Kingship, and found that the Queen of England was not to put out her hand to a Jewish Rabbi (A Jewish Rabbi!).
Rabbi Sufrin meets the Queen of England: Rabbi Aryeh Sofrin was anxious just like the scores of other people scheduled to meet the Queen of England, but for a different reason: what would he do if she reached out for a handshake? The Chabad shaliach to Ilford, Essex, located northeast of London, was about to be dubbed Member of the British Empire for 18 years of work as head of a drug and alcohol rehabilitation center that serves Jews, Christians and Muslims – and even has an imam on the staff. He had been briefed on proper protocol, but did not know what to do about the handshake that ends every audience with the Queen. And on this particular day, she had chosen not to wear her glove. But she must have been briefed about him, concludes Rabbi Sofrin, because at the end of their short meeting the 83-year-old Queen Elizabeth II remembered to avoid the customary handshake.
 If one does so to an Erva, which is every Jewish girl above the age of 11, then doing so contains a Biblical prohibition. [Michaber Even Haezer 21/1; Shach 157/10; 195/20;] Even if the woman is not an Erva, doing so would be at least Rabbinically forbidden. Regarding if shaking hands with a gentile man/woman is Biblically or Rabbinically forbidden [as they are not defined as Ervas], seemingly it is only Rabbinically forbidden being that there is no Kareis involved in their relationship. [See Shach 157/10] However, nevertheless it would still be included in the command of Yaharog Veal Yaavor. [see Shach ibid]
 See Shach 157/10; 195/20; Od Yosef Chaiy Shoftim p. 151
 Shemos Raba Bo 16 “A woman who is not yours is forbidden to be touched at all”; Shaareiy Teshuvah 3/80 “It is forbidden for ones hand to touch the hand of a married woman [or any Erva]” Sefer Chassidim 1090 “One is not to shake hands with a gentile woman”; Od Yosef Chaiy Shoftim p. 151 “it is certainly forbidden to shake hands with a Jewish woman”; Sdei Chemed 3 Mareches Kuf Klal 7; Mareches Chasan Vekalah 12 and 26; Makor Chesed on Sefer Chassidim ibid in name of Rav Meir Arik from fact he only allows if the hand is covered; Igros Moshe O.C. 1/113 “Certainly it is forbidden to do so”; E.H. 1/56 and 4/32-9; Mishneh Halachos 6/223; Otzer Haposkim 20/3-1; Yalkut Yosef Even Haezer 21/21; Nitei Gavriel 52/1; Az Nidbaru 2/73
 The reason: As a handshake inherently represents an act of affection, and it is forbidden to affectionately touch any woman, as stated above. [Od Tosef Chaiy ibid; Igros Moshe ibid] Furthermore, even if one were to determine that it does not contain any affection, and is merely a cordial hand shake, one is not to do so in order to distance oneself from Giluiy Arayos. [Implication of Sefer Chassidim ibid; See also Ezer Mekodesh 20/1] Some rule this is Rabbinically forbidden, as the Sages forbade any form of touch even not of affection. [Beis Yosef 195; Sdei Chemed ibid]
 Sefer Chassidim 1090; Od Yosef Chaiy Shoftim p. 151; Poskim in Nitei Gvariel 52/1 footnote 2
Other opinions: Some write that if the hand is covered by a cloth then it is permitted to shake the hand. [Makor Chesed on Sefer Chassidim ibid in name of Rav Meir Arik based on Tosafus Menachos 61b in name of Yerushalmi that allows the Kohen to place his hand under the hand of the Karban owner]
 Od Yosef Chaiy Shoftim p. 151 based on Sefer Chassidim ibid
 Basra 1/1; Kama 1/3; based on Tur brought in Rama 1/1
This is the first matter mentioned in the Mishneh being that it is a great component of service of G-d as at times one desires to do a Mitzvah and avoids doing so due to scoffers. [Tur] This is the foundation of all one’s service of G-d. [Toras Menachem 22 p. 38]
 Koveitz Ledavid Tzevi of Rav Shlomo Karlebach, Rav in Germany in the 1800’s; Nishmas Chaim 135/6 of the son of the Netziv; See Igros Moshe E.H. 1/56 and 4/32-9 “There are some even G-d fearing Jews that are lenient in this, seemingly due to that they do not consider it an act of affection, however it is difficult to rely on this ruling”; This is especially the approach of those which affiliate with Modern Orthodoxy: See Bnei Banim 1/39 of Rav Yehuda Hertzel [M. O. Rav]; It is recorded that certain Rabbanim shook hands with woman in the above specified situations such as Rav Unterman; Rav Y.B Soloveichek; Rav Yitzchak Hutner. The above claims have not been verified.
 However, in modern orthodox circles, certain leniencies are given in specific situations in which there is certainly no affection intended in the hand shake [such as to avoid embarrassing the person, or causing enmity of Jews].
 See Divrei Pinchas 60/41, Chief Rabbi of Hague, for his experiences;
 Brought in Nitei Gavriel Yichud 52 footnote 2
 Yalkut Yosef Sova Semachos 1/274
 Published on http://www.vosizneias.com/41842/2009/11/10/london-the-queen-knew-not-to-shake-hands-with-the-chabad-shaliach/