Torture (karana) is the deliberate infliction of physical or psychological pain by one or more persons on another. When pain is self inflicted as is sometimes done for religious reasons, it is properly called self-mortification (attakilamatha). Torture is used to extract confessions or information, as a punishment, out of revenge, or to create an atmosphere of fear amongst the wider population. Less commonly, psychopaths sometimes torture their victims for pleasure. Torture was probably done for all these reasons during the time of the Buddha, although only judicial torture is mentioned in the Tipiṭaka. A certain type of legal officer whose job it was to investigate crimes routinely brutalized suspects and judges often handed down punishments that included torture (S.II,258). The Koliyans had a type of policemen with a distinctive headdress and a reputation for cruelty. In his conversation with the Buddha, Pataliya said of these officers, `If there are any wicked rogues among the Koliyans, it is they.' (S.IV,341). Some of the types of torture mentioned in the texts include flogging, scolding with boiling oil, burying alive up to the neck, amputation of limbs, nose and ears, impaling and being trampled by elephants. According to one account, an enraged king tortured a man by having a nest of stinging red ants broken over his head (J.IV,375). In the Majjhima Nikāya the Buddha lists some of the dreadful tortures that were inflicted on criminals as a punishment, all of which would have resulted in death (M.I,87). No doubt executioners (coraghātaka) and prison guards (bandhanāgarika) were mentioned by the Buddha as having a cruel livelihood because they often committed such cruelties (M.I,343). To countenance torture or to inflict it would go against the most basic Buddhist principles of kindness, compassion and justice.
In 1252 Pope Innocent IV issued a bull entitled Ad Exsitirpanda authorizing torture during the questioning of heretics and apostates. The Inquisition continued to use torture up until the 19th century in the Papal States, Goa, Mexico, the Philippines, etc. In other parts of Western Europe and the US torture as a judicial procedure began to become unacceptable in the 18th century and by the end of the 19th century it had become illegal in these places. It was informally reintroduced and widely used by the police and military during the Nazi period in Germany and became legal again in the USSR from 1931 until the 1950s.  Certain types of torture, to be used under certain circumstances,  were legalized in the US in 2006 and banned again in 2009. Although illegal in all Buddhist countries torture is still common in prisons and police stations.