Sadism and masochism as medical terms
Sadism and masochism, in the sense, describe psychiatric disorders characterized by feelings of sexual pleasure or gratification when inflicting suffering or having it inflicted upon the self, respectively. Sadomasochism is used in psychiatry to describe either the co-occurrence of sadism and masochism in one person as separate disorders, or as a replacement for both terms, depending on the theory used. Definitions of sadism and masochism in medicine have been modified repeatedly since they were introduced by the Austrian psychiatrist Richard Freiherr von Krafft-Ebing in the 19th century (Krafft-Ebing 1901).
This article focuses on the development of sadism and masochism as medical terms, leading to their current definitions as paraphilia in the Diagnostic and Statistical Manual of Mental Disorders (DSM). It does not cover sadomasochism as an erotic practice, discussions of the sadomasochistic subculture or other matters relating to consensual sadism and masochism. However, because this article touches the history of those terms, there are references to BDSM.

# Early descriptions
Sadistic and masochistic behavior was known before Krafft-Ebing. In 1498, the Italian philosopher Pico della Mirandola described a man who needed to be flogged before he could have sex (Farin 1990). In 1639, the German physician Johann Heinrich Meibom introduced the first theory of masochism (Meibom  1718) : Based on the contemporary understanding of anatomy, he postulated that flogging the back warms the semen in the kidneys, which causes sexual excitement once it reaches the testicles. Kristian Frantz Paullini modified this in 1698 so that warm blood, not semen, descends from the kidneys, but the basic theory remained unchallenged until Krafft-Ebing. It was expanded by Francois Amedee Doppet in 1788 to include women by assuming the same effect on the female genitalia (Doppet  1885).
Also, sadomasochism as a sexual practice was well known in literature before the works of the Marquis de Sade. The Kama Sutra, dated roughly at the 4th century AD, describes consensual erotic slapping. In his novel Fanny Hill  published 1749, the British author John Cleland has the protagonist whip a young man in a brothel. In his autobiography Confessions, the French philosopher Jean-Jacques Rousseau described his unhappiness at his masochistic fantasies.
Unlike other practices that were previously classified as perversions such as homosexuality or zoophilia, there is no explicit taboo of sadomasochistic behavior in the Bible.

# Krafft-Ebing and the Psychopathia Sexualis
Krafft-Ebing published his first version of the Psychopathia Sexualis, a collection of bizarre sexual case histories and sex-crimes, in 1886. The terms "sadism" and "masochism" were introduced in later editions. "Sadism" was taken from what Krafft-Ebing knew of the life and writings of the Marquis de Sade (important parts of Sade's work, such as The 120 Days of Sodom, were not published until later). Sade had died in 1814. For "masochism", Krafft-Ebing chose the name of a contemporary, the Austrian author Leopold von Sacher-Masoch. "Sadism" and "masochism", however, stem from quite different logics of sexuality and erotism, as do Sade's and Sacher-Masoch's work (Gilles Deleuze has exposed this point in his presentation of Sacher-Masoch).
Krafft-Ebing's basic assumption was that all forms of sex not directly related to procreation were perversions. He described sadism and masochism in terms of the theory of degeneration as published by Benedict Morel. This stated that characteristics such as perversions can be inherited (Morel 1957). In other words, people who engage in what was considered amoral or damaging sexual behavior -- such as masturbation -- could pass these tendencies on to their children, leading to a steady deterioration of humanity's gene pool. This theory has been disproven.
Krafft-Ebing saw a basic and natural tendency in men towards sexual sadism and a natural tendency of women towards sexual masochism, a view that would be expanded by psychoanalysis.
Other contemporary researchers doubted Krafft-Ebing's findings or suggested modifications. The British physician Havelock Ellis noted that enjoyment of pain was restricted to an erotic context (Ellis  1967). In 1892, Albert von Schrenck-Notzing introduced the term Algolagnia as an alternative form of description (Schrenck-Notzing 1892). However, Krafft-Ebing's theories were adopted by Sigmund Freud and became an integral part of psychoanalysis, thereby ensuring their predominance.

# Freud and psychoanalysis
Freud made masochism and -- to a lesser degree -- sadism core parts of psychoanalysis. In Three Essays on the Theory of Sexuality he called the tendency to inflict and receive pain during sex "the most common and important of all perversions" (Freud  1996). He also pointed out that both tendencies commonly occurred in the same individual.
Freud changed his theories on the genesis of sadism and masochism repeatedly, first stating that masochism only arose as a form of sadism against the self. He later introduced such concepts as "primary" and "secondary" masochism and sub-forms such as "feminine" and "moral" masochism. He also saw guilt as an important factor and integrated both tendencies into his theory of psychosexual development. Put shortly, they were assumed to be a sign of incomplete or incorrect sexual development in the child.
Freud's followers such as Carl Jung, Wilhelm Reich and Theodor Reik expanded and modified his ideas, creating new terms and concepts in the process. Elsworth Baker attributed the origin of masochistic character to parental inconsistency. Helene Deutsch postulated that all women are masochistic by nature (Deutsch 1930), reinforcing Krafft-Ebing's and Freud's views. Some theorists claimed that the population of whole countries such as Japan should be considered masochistic in a psychoanalytical sense (Nakakuki 1994). Because of these modifications, even the most basic words such as "masochism" have acquired so many different meanings in psychoanalysis that the terms have become confusing for psychoanalysts themselves and incomprehensible to outsiders (Maleson 1984).
Freud's theories on sadomasochism and the philosophy of Sade fascinated thinkers such as Gilles Deleuze and Simone de Beauvoir. Their writings, though not grounded in formal research and sometimes far removed from real-life sadomasochism, strongly influenced popular views of the subject in the mid-20th century.

# Empirical research
Outside of psychoanalysis, views on sadomasochism began to change in the late 20th century with the study of actual behavior of real-life sadomasochists. Sadomasochistic tendencies in both genders were noted by Alfred Kinsey as part of his reports. The first researcher to describe the existence of a sadomasochistic subculture was Robert Litman in 1972 (Litman 1972).
The first large-scale empirical study on sadomasochism was conducted by Andreas Spengler in 1977. Spengler, a German physician, used questionnaires to gain basic data (Spengler 1977). His results contradicted most earlier work, especially that of the psychoanalysts, leading him to conclude that previous research was "heavily burdened with prejudice and ignorance" (Spengler 1979). When Norman Breslow expanded on this, he found only five previous empirical studies in all scientific literature, including Spengler's (Breslow 1985). Beslow was also the first to show that non-prostitute women make up a significant part of the sadomasochistic subculture (Beslow 1985). No empirical study has found a connection to violent crimes or evidence for an increased tendency towards sociopathological behavior in sadomasochists as had been generally assumed since Krafft-Ebing.
The realization that far more people than previously assumed practice sadomasochism and that sadomasochists form subcultures led to an influx of researchers from outside medicine. The anthropologist Paul Gebhard described sadism and masochism in a cultural context (Gebhard 1969). Again in Germany, Thomas Wetzstein conducted a large-scale study of the local subculture from a sociological viewpoint, confirming Spengler's results and expanding on them (Wetzstein 1993). One major change effected by these studies was the realization that women do not limit themselves to a masochistic role. Much of this modern research is less concerned with what causes sadistic and masochistic urges than describing their mechanisms and characteristics.

# Research and mainstream culture
The results of the empirical studies and an increasingly tolerant attitude towards sexual minorities led to more and more sadomasochists forming public groups, for example the Eulenspiegel Society in 1971. This is especially true in countries where sadomasochism between consenting adults is legal such as Germany  or Norway . As a result, sadomasochism became much more present in mainstream western and Japanese culture. Furthermore, sadomasochists themselves have started presenting their own views through books or the media. Examples of this include Maria Marcus in Denmark (Marcus 1974), Pat Califia in the USA (Califia 1980), Vanessa Duries in France (Duries 1993), and Kathrin Passig in Germany (Passig 2000).

# Sadism and masochism today
The results of the newer studies have led to calls to abolish sadism and masochism as disease categories completely, arguing that the truly pathological forms are adequately covered by other diagnoses. The sadomasochistic subculture added a political dimension to this drive with claims of discrimination and by pointing to the precedent of removing of homosexuality from the list of mental disorders .
In response, the American Psychiatric Association modified the criteria for sadism and masochism in the Diagnostic and Statistical Manual of Mental Disorders (DSM IV) in 1994 so that consensual sadomasochistic behavior alone is not considered a sexual disorder anymore. In the DSM-IV TR, published in 2000, sadomasochistic behavior can be diagnosed if the patient "has acted on these urges with a non-consenting person" or "the urges, sexual fantasies, or behaviors cause marked distress or interpersonal difficulty"  , so consensual sadomasochism can no longer be considered a disease unless it causes severe discomfort.  In 1995, Denmark became the first country to completely remove sadomasochism from its classification of diseases .