LGBT rights by country or territory

Rights affecting lesbian, gay, bisexual, and transgender (LGBT) people vary greatly by country or jurisdiction – encompassing everything from the legal recognition of same-sex marriage to the death penalty for homosexuality.
Notably, , 29 countries recognized same-sex marriage. By contrast, not counting non-state actors and extrajudicial killings, only one country is believed to impose the death penalty on consensual same-sex sexual acts: Iran. The death penalty is officially law but generally not practiced in Afghanistan, Brunei, Mauritania, Nigeria (in the northern third of the country), Saudi Arabia, Somalia (in the autonomous state of Jubaland) and the United Arab Emirates. Sudan rescinded its unenforced death penalty for anal sex (hetero- or homosexual) in 2020. Fifteen countries have stoning on the books as a penalty for adultery, which would include gay sex, but this is only enforced by the legal authorities in Iran.
In 2011, the United Nations Human Rights Council passed its first resolution recognizing LGBT rights, following which the Office of the United Nations High Commissioner for Human Rights issued a report documenting violations of the rights of LGBT people, including hate crimes, criminalization of homosexual activity, and discrimination. Following the issuance of the report, the United Nations urged all countries which had not yet done so to enact laws protecting basic LGBT rights.
Scope of laws.
Laws that affect LGBT people include, but are not limited to, the following:
History of LGBT-related laws.
Ancient India.
Ayoni or non-vaginal sex of all types are punishable in the Arthashastra. Homosexual acts are, however, treated as a smaller offence punishable by a fine, while unlawful heterosexual sex carries much harsher punishment. The Dharmsastras, especially the later ones, prescribe against non-vaginal sex like the Vashistha Dharmasutra. The Yājñavalkya Smṛti prescribes fines for such acts including those with other men. Manusmriti prescribes light punishments for such acts. Vanita states that the verses about punishment for a sex between female and a maiden is due to its strong emphasis on a maiden's sexual purity.
Ancient Israel.
The ancient Law of Moses (the Torah) forbids men from lying with men (i.e., from having intercourse) in Leviticus 18 and gives a story of attempted homosexual rape in Genesis 19, in the story of Sodom and Gomorrah, after which the cities were soon destroyed with "brimstone and fire, from the Lord" and the death penalty was prescribed to its inhabitants – and to Lot's wife, who was turned into a pillar of salt because she turned back to watch the cities' destruction. In Deuteronomy 22:5, cross-dressing is condemned as "abominable".
Assyria.
In Assyrian society, sex crimes were punished identically whether they were homosexual or heterosexual. An individual faced no punishment for penetrating someone of equal social class, a cult prostitute, or with someone whose gender roles were not considered solidly masculine. Such sexual relations were even seen as good fortune, with an Akkadian tablet, the "Šumma ālu", reading, "If a man copulates with his equal from the rear, he becomes the leader among his peers and brothers". However, homosexual relationships with fellow soldiers, slaves, royal attendants, or those where a social better was submissive or penetrated, were treated as bad omens.
Middle Assyrian Law Codes dating 1075 BC has a particularly harsh law for homosexuality in the military, which reads: "If a man have intercourse with his brother-in-arms, they shall turn him into a eunuch." A similar law code reads, "If a seignior lay with his neighbor, when they have prosecuted him (and) convicted him, they shall lie with him (and) turn him into a eunuch". This law code condemns a situation that involves homosexual rape. Any Assyrian male could visit a prostitute or lie with another male, just as long as false rumors or forced sex were not involved with another male.
Ancient Rome.
In ancient Rome, the bodies of citizen youths were strictly off-limits, and the "Lex Scantinia" imposed penalties on those who committed a sex crime "(stuprum)" against a freeborn male minor. Acceptable same-sex partners were males excluded from legal protections as citizens: slaves, male prostitutes, and the "infames", entertainers or others who might be technically free but whose lifestyles set them outside the law.
A male citizen who willingly performed oral sex or received anal sex was disparaged, but there is only limited evidence of legal penalties against these men. In courtroom and political rhetoric, charges of effeminacy and passive sexual behaviors were directed particularly at "democratic" politicians "(populares)" such as Julius Caesar and Mark Antony.
Roman law addressed the rape of a male citizen as early as the 2nd century BC, when it was ruled that even a man who was "disreputable and questionable" had the same right as other citizens not to have his body subjected to forced sex. A law probably dating to the dictatorship of Julius Caesar defined rape as forced sex against "boy, woman, or anyone"; the rapist was subject to execution, a rare penalty in Roman law. A male classified as "infamis", such as a prostitute or actor, could not as a matter of law be raped, nor could a slave, who was legally classified as property; the slave's owner, however, could prosecute the rapist for property damage.
In the Roman army of the Republic, sex among fellow soldiers violated the decorum against intercourse with citizens and was subject to harsh penalties, including death, as a violation of military discipline. The Greek historian Polybius (2nd century BC) lists deserters, thieves, perjurers, and "those who in youth have abused their persons" as subject to the "fustuarium", clubbing to death. Ancient sources are most concerned with the effects of sexual harassment by officers, but the young soldier who brought an accusation against his superior needed to show that he had not willingly taken the passive role or prostituted himself. Soldiers were free to have relations with their male slaves; the use of a fellow citizen-soldier's body was prohibited, not homosexual behaviors per se. By the late Republic and throughout the Imperial period, there is increasing evidence that men whose lifestyle marked them as "homosexual" in the modern sense served openly.
Although Roman law did not recognize marriage between men, and in general Romans regarded marriage as a heterosexual union with the primary purpose of producing children, in the early Imperial period some male couples were celebrating traditional marriage rites. Juvenal remarks with disapproval that his friends often attended such ceremonies. The emperor Nero had two marriages to men, once as the bride (with a freedman Pythagoras) and once as the groom. His consort Sporus appeared in public as Nero's wife wearing the regalia that was customary for the Roman empress.
Apart from measures to protect the prerogatives of citizens, the prosecution of homosexuality as a general crime began in the 3rd century of the Christian era when male prostitution was banned by Philip the Arab. By the end of the 4th century, after the Roman Empire had come under Christian rule, passive homosexuality was punishable by burning. "Death by sword" was the punishment for a "man coupling like a woman" under the Theodosian Code. Under Justinian, all same-sex acts, passive or active, no matter who the partners, were declared contrary to nature and punishable by death.
British Empire.
The United Kingdom introduced anti-homosexuality laws throughout its colonies, particularly in the 19th century when the British Empire was at its peak. As of 2018, more than half of the 71 countries that criminalised homosexuality were former British colonies or protectorates.