Some or all sexual acts between men, and less frequently between women, have been classified as a criminal offense in various regions. Most of the time, such laws are unenforced with regard to consensual same-sex conduct, but they nevertheless contribute to police harassment, stigmatization, and violence against homosexual and bisexual people. Other effects include exacerbation of the HIV epidemic due to the criminalization of men who have sex with men, discouraging them from seeking preventative care or treatment for HIV infection.
The criminalization of homosexuality is often justified by the scientifically discredited idea that homosexuality can be acquired or by public revulsion towards homosexuality, in many cases founded on the condemnation of homosexuality by the Abrahamic religions (Judaism, Christianity, and Islam). Arguments against the criminalization of homosexuality began to be expressed during the Enlightenment. Initial objections included the practical difficulty of enforcement, excessive state intrusion into private life, and the belief that criminalization was not an effective way of reducing the incidence of homosexuality. Later objections included the argument that homosexuality should be considered a disease rather than a crime, that criminalization violates the human rights of homosexuals, and that homosexuality is not morally wrong.
In many countries, criminalization of homosexuality is based on legal codes inherited from the British Empire. The French colonial empire did not lead to criminalization of homosexuality, as this was abolished in France during the French Revolution in order to remove religious influence from the criminal law. In other countries, the criminalization of homosexuality is based on sharia law. In the Western world, a major wave of decriminalization started after World War II. It diffused globally and peaked in the 1990s. In recent years, many African countries have increased enforcement of anti-homosexual laws due to politicization and a mistaken belief that homosexuality is a Western import. As of 2024[update], homosexuality is criminalized de jure in 61 UN member states and de facto in two others; at least seven of these have a death penalty for homosexuality.