The history of lesbian, gay, bisexual and transgender people (LGBT) in Russia and its historical antecedents (i.e., the Soviet Union, the Russian Empire) has largely been influenced by the political leanings and levels of liberalism or tolerance of the rulers. It has also been influenced by the historically prohibitive nature of Russian Orthodox religiosity regarding sexuality.
Homosexuality has been documented in Russia for centuries. The earliest documented bans on homosexuality date to the early-mid 17th century. Gregory Karpovich Kotoshikhin recorded during the reign of Czar Alexis Mikhailovich that male homosexuals were put to death, and also states that female homosexuals are also put to death by burning. Government attempts at preventing homosexual practices began in the 18th century, with Tsar Peter the Great banning homosexual relations in the armed forces in 1716, as a part of his attempt to modernise the country. In 1832 further laws were enacted criminalising certain sexual acts between two males; however, an LGBT subculture developed in Russia during that century, with many significant Russians being openly homosexual or bisexual.
In 1917, the Russian Revolution saw the overthrow of the Tsarist government, and the subsequent foundation of the Russian SFSR, the world's first socialist state, followed by the founding of the Soviet Union after the end of the civil war in 1922. The new Communist Party government eradicated the old laws regarding sexual relations, effectively legalising homosexual activity within Russia, although it remained illegal in other former territories of the Russian Empire. Under Lenin's leadership, openly gay people were allowed to serve in government. In 1933, the Soviet government, under the leadership of Joseph Stalin, recriminalised homosexual activity with punishments of up to five years' hard labor. Following Stalin's death, there was a liberalisation of attitudes toward sexual issues in the Soviet Union, but homosexual acts remained illegal. Nonetheless, homosexual culture became increasingly visible, particularly following the glasnost policy of Mikhail Gorbachev's government in the late 1980s.