Judaism prohibits shaving with a razor on the basis of a rabbinic interpretation of Leviticus 19:27, which states, "Ye shall not round the corners of your heads, neither shalt thou mar the corners of thy beard." The Mishnah interprets this as a prohibition on using a razor on the beard.

This prohibition is further expanded upon in kabbalistic literature.

In the Torah
The book of Leviticus in the Torah makes mention of corners of the head, and prohibits the marring of the corners of the beard, with particular emphasis on priests (kohanim) not marring the corners of the beard; as with many other parts of Leviticus, the Book of Ezekiel describes different regulations, stating that the priests should not shave their heads, or let their locks grow long.

However, there were exceptions, with the Book of Ezekiel itself adding that priests should keep their hair trimmed, and Leviticus arguing that, in certain cases of tzaraath, the beard and hair should be completely shaved away. Numbers (Ch. 6) additionally requires that Nazarites shave their heads, 7 days after any contact with corpses.

Origin
According to biblical scholars, the shaving of hair, particularly of the corners of the beard, was originally a mourning custom; the behaviour appears, from the Book of Jeremiah, to also have been practiced by other Semitic tribes, although some ancient manuscripts of the text read live in remote places rather than clip the corners of their hair. Biblical scholars think that the regulations against shaving hair may be an attack on the practice of offering hair to the dead, which was performed in the belief that it would obtain protection in sheol; Nazirites shaved after contact with a corpse, captive women shaved after mourning the death of their parents, and the general prohibition in the Holiness Code is immediately followed by a rule against people cutting their own bodies for the benefit of the dead.

Textual scholars date the Priestly Source, and the Holiness and Priestly Codes within it, to the late 7th century or later; it appears that before this time, the shaving of the head during mourning was permitted, and even encouraged. The Book of Amos, which is dated by textual scholars to the mid 7th century, as well as the Books of Isaiah and of Micah, which textual scholars date to a slightly later period, portray God as instructing the Israelites to shave their head as an act of mourning:
... God ... called you to weep and mourn. He told you to shave your heads in sorrow for your sins-

The prohibition against cutting the corners of the beard may also have been an attempt to distinguish the appearance of Israelites from that of the surrounding nations, and reduce the influence of foreign religions; Maimonides criticises it as being the custom of idolatrous priests. The Hittites and Elamites were clean-shaven, and the Sumerians were also frequently without a beard; conversely, the Egyptians and Libyans shaved the beard into very stylised elongated goatees.

In classical rabbinical literature
The forbidding of shaving the corners of the head was interpreted by the Mishnah as prohibiting the hair at the temples being cut so that the hairline was a straight line from behind the ears to the forehead; thus it was deemed necessary to retain sidelocks, leading to the development of a distinctly Jewish form of sidelock, known as payot. As for the beard, more complicated views arose; the corners of the beard were explained to refer to five extremities in the Talmud. There are many opinions in medieval scholars as to what these five points are. For example, it may be a point on each cheek near the temples, a point at the end of the cheek bone towards the centre of the face, and the point of the chin. Or it may be two on the mustache, two somewhere on the cheek, and one on the point on the chin. As a result, Shulchan Aruch prohibits the shaving of the entire beard and mustache.

Because the biblical prohibition against shaving uses the Hebrew word gelech (גלח), which refers to shaving with a blade against the skin, Talmudic rabbis interpreted it to only refer to a blade, and only to the hair being cut close to the roots, in a smooth manner. This means that only a razor would be prohibited, trimming or non-razor shaving would be permitted. In the ancient land of Israel, it was common among more scholarly circles of Jews to clip beards.

Ezekiel's request for priests to keep their hair trimmed was read by the Talmudists as referring specifically to the artistic Lydian style of haircut, in which the ends of the hair of one row reaches the roots of the next. This hairstyle was apparently a distinguishing feature of the nobility, as the common population shaved their heads entirely except for the sidelocks; the king is said to have had his hair cut in this manner each day, the Jewish High Priest to have done so each week just before the Sabbath, and ordinary Jewish priests to have done so every thirty days. The Talmudic Rabbis also argue that anyone who was constantly in contact with government officers could adopt tonsures, although they do state that to everyone else it was forbidden; during the period of Hellenic domination over Judah, the tonsure was a fashionable haircut among the Greeks.

In rabbinic literature of the Middle Ages 
The Shulchan Aruch quotes the Talmud that because scissors have two blades, it would therefore be permitted to trim the beard by using them, since the cutting action would come from contact between two blades and not from that between blade and skin. In Germany and Italy, by the end of the seventeenth century, Jews started removing beards with the aid of pumice stones and chemical depilatories, which would leave the face smooth, as if it had been shaven. These are non-razor shaves which are not prohibited. Menachem Mendel Schneersohn (Tzemach Tzedek) argued that shaving a beard would fall under the biblical regulation against males resembling a female (he also extended the prohibition for wanton destruction to destroying the hair of the beard); the Shulchan Aruch interpreted this regulation in a different way, arguing that it forbade men from removing hair from areas where women were accustomed to remove hair, such as underarm hair and pubic hair.

In the early Middle Ages, Jewish custom, in regard to beards, followed the fashions of each nation; in Germany, France, and Italy, Jews removed their beards, but in Islamic nations, Jews grew them long. In 1720, a mild confrontation arose between a group of Italian Jews, who had migrated to Salonica in the Ottoman Empire, and the local Jewish population, because the migrant Italians didn't wear beards, but the local population insisted that beards should be worn. It was later remarked by Jacob Emden that the Jewish population in western Europe had objected to these regulations so much that it had been impractical to enforce them; there had also been prominent opponents of beards, such as Joseph Solomon Delmedigo, to whom is attributed the epigram:

In Kabbalah 
The Zohar, one of the primary sources of Kabbalah (a form of Jewish mysticism), attributes holiness to the beard, and strongly discourages its removal, declaring that even the shortening of a beard by scissors is a great sin; it was even said that Isaac Luria, a significant figure in the history of Kabbalistic mysticism, meticulously avoided touching his beard, lest he should accidentally cause hairs to drop from it. Kabbalistic teachings gradually spread into Slavonic regions, and consequently beard trimming was discouraged in these areas, even if it involved scissors; it was the Hasidic Jews who more closely followed Kabbalistic practices than Jews of a Lithuanian or Misnagdish background, and thus it became the Hasidic Jews who are known for the distinctive traditional practice of growing their beards. However, in Italy, shaving the beard was so popular that even the Italian followers of Kabbalah did it; an Italian Kabbalist even went to the extent of arguing that beard shaving was only prohibited in Canaan, and was actually to be encouraged elsewhere.

Electric shavers 
 
In Leviticus 19:27, Jews are prohibited from "destroying" the corners of the beard. The Talmud (Makkos 20a) has different views on this, to mean the use of a single-bladed razor (as opposed to any scissors-like device which requires two blades to cut) or to remove any beard hair even with tweezers. Therefore, Jewish males may not use a razor to cut certain parts of their beards. For practical purposes, those who comply with halacha as defined by Rabbinic Judaism refrain from the use of razors altogether.

Many Orthodox Jews, especially Haredi Orthodox Jews, refrain from cutting their beards altogether, and, with the exception of occasionally trimming their mustaches with scissors when they interfere with eating, never cut their facial hair. Orthodox Jews who do shave their facial hair must utilize electric shavers, as opposed to razors.

Some modern Jewish religious legislators in Orthodox Judaism, including Rabbi Moshe Feinstein and Rabbi Yosef Eliyahu Henkin, permit the use of electric razors for the purpose of remaining clean-shaven, because, in their view, electric razors work like scissors, cutting by trapping hair between the blades and a metal grating. However, other modern rabbinical authorities, such as Rabbi Avraham Yeshayahu Karelitz and Rabbi Yaakov Yisrael Kanievsky, consider electric razors, particularly rotary models which use "Lift and Cut" heads made by Philips, to work in the manner of primitive razors, and consequently prohibit their use. According to some interpretations of the permissive view, these shavers can be used if the lifters attached to the shaver's cutters are removed first. According to other interpretations of this view, these shavers can be used without removing the lifters, and, indeed, according to some, it may even be preferable not to do so.

The rotary electric shaver was invented by a Jewish engineer named Alexandre Horowitz. Many Orthodox Jews prefer to grow beards, for a variety of religious, social, and cultural reasons, even if they believe that electric shavers would be permitted; many Orthodox Jews, even Hasidic Orthodox Jews, today grow beards to keep the tradition of their ancestors, regardless of the permissibility of their removal.
 
Kosher depilating chemicals were also a common way to remove hair in accordance of the religion.

Mourning (including Sefirat Haomer and The Three Weeks)
Orthodox Jewish mourners do not shave or get a haircut for thirty days. This refers to those who are observing one of the seven types of personal loss: Father, Mother, Spouse, Brother, Sister, Son, Daughter.

There is another type of mourning. Haircut and shaving customs apply, each according to custom, for the communal mourning during The Three Weeks, and to part or all of the period known as Sefirat Haomer.

Body and pubic hair removal for men 
The Talmud prohibits men from shaving their body and pubic hair because such activity is considered feminine behavior, violating the prohibition of: "A man shall not put on a woman’s garment." Male Ashkenazi Jews followed the Talmudic law as they lived in a European society in which such shaving was regarded as feminine. Sephardic men since the Geonic era have shaved their body and pubic hair as this was the practice amongst Muslim men of their society.

Antisemitic attacks
During twentieth century antisemitic violence, especially the Holocaust, Germans and other perpetrators would forcibly shave Jewish men as a form of humiliation.

See also

Payot

References 

Jewish law and rituals
Shaving
Negative Mitzvoth