The history of LGBTQ in Russia and its historical antecedents (the Soviet Union and the Russian Empire) has largely been influenced by the political leanings of its rulers. Medieval Catholic-Protestant Europe had the largest influence on Russian attitude towards homosexuality. Russian LGBT history was influenced by the ambivalent attitude of the Russian Orthodox religiosity regarding sexuality.

Under the reign of Peter the Great in the 18th century, who introduced a wide range of reforms aimed at modernizing and Westernizing Russia, male homosexual activity was banned only for soldiers in military statutes. In 1832, the criminal code included Article 995, which stated that "muzhelozhstvo", or men lying with men, was a criminal act punishable by exile to Siberia for up to five years. Men lying with men was interpreted by courts as meaning anal sex. Application of the laws was rare, and the turn of the century found a relaxation of these laws and a general growing of tolerance and visibility.

In the wake of the October Revolution, the Bolshevik government decriminalized homosexuality. The Bolsheviks rewrote the constitution and "produced two Criminal Codes – in 1922 and 1926 – and an article prohibiting homosexual sex was left off both." The new Communist Party government removed the old laws regarding sexual relations, effectively legalising homosexual activity within Russia, although it remained illegal in other territories of the Soviet Union, and the homosexuals in Russia were still and sacked from their jobs. Under Joseph Stalin, the Soviet Union recriminalized homosexuality in a decree signed in 1933. The new Article 121, which punished "muzhelozhstvo" with imprisonment for up to five years, saw raids and arrests. Female homosexuals were sent to mental institutions. The decree was part of a broader campaign against "deviant" behavior and "Western degeneracy". Following Stalin's death, there was a liberalisation of attitudes toward sexual issues in the Soviet Union, but homosexual acts remained illegal. Discrimination against LGBT individuals persisted in the Soviet era, and homosexuality was not officially declassified as a mental illness until 1999.

Soviet Article 121 was often commonly used to extend prison sentences and to control dissidents. Among those imprisoned were the well-known film director Sergei Paradjanov and the poet Gennady Trifonov. Under Mikhail Gorbachev's administration in the late 1980s, the first gay organization came into being. The Moscow Gay & Lesbian Alliance was headed by Yevgeniya Debryanskaya and Roman Kalinin, who became the editor of the first officially registered gay newspaper, Tema. The fall of the USSR accelerated the progress of the gay movement in Russia. Gay publications and plays appeared. In 1993, a new Russian Criminal Code was signed, without Article 121. Men who had been imprisoned began to be released.

Since 2000, a campaign by Russian president Vladimir Putin and the Russian Orthodox Church to promote "traditional Russian values" and oppose "liberalism" in regards to homosexuality has led to many pieces of anti-LGBT legislation being passed federally, including the banning of distribution of "propaganda of non-traditional sexual relationships to minors" in 2013, an amendment in Russia's constitution banning same-sex marriage passed in 2020, and expansion of the 2013 propaganda law signed in 2022 to apply it to anyone, regardless of age.

Muscovite Russia

The Austrian royal councilor Sigismund von Herberstein described in his report Rerum Moscoviticarum Commentarii (Notes on Muscovite Affairs) his observations during his travels in Moscow in 1517 and 1526. He stated that homosexuality was present among all social classes. The English poet George Turberville who visited Moscow in 1568 when Ivan IV ruled Russia during a bloody phase, was not shocked by the carnage, but about the open homosexuality of the Russian peasants. Adam Olearius also reported that homosexuality among men existed on all levels of society and was not treated as a crime. There are also reports of homosexual relationships between women. Testimony of contemporaries in this regard is probably exaggerated, since any tolerant attitude towards homosexuals was equated to sodomy. In 1551, at the ("hundred-domed Cathedral"), a real ecclesiastical, but not criminal, punishment for a homosexual act was introduced - excommunication, but the spread of this punishment is doubtful, since the homosexual act was "nothing more than a joke" at the tsar's court and among the people. Ivan the Terrible was accused of being homosexual in an attempt to discredit him. Despite this, there have been outbreaks of homophobia, for example when Tsar False Dmitry I was overthrown, his broken body was dragged through the streets by his genitals alongside his supposed male lover.

Russian Empire In 1706, under Peter the Great the first homophobic provision appeared, which provided for the death penalty in the army for a homosexual act, but 10 years later the decision was relaxed: corporal punishment was provided for a voluntary sexual act, and exile for rape. Such laws did not apply to civil society until 1832.

In 1832, Tsar Nicholas I added Article 995 which outlawed muzhelozhstvo (archaic Russian term for sodomy). While this could have created a ban on all forms of private adult voluntary homosexual behavior, the courts tended to limit its interpretation to anal sex between men, thus making private acts of oral sex between consenting men legal. The law did not explicitly address female homosexuality or cross-dressing, although both behaviors were considered to be equally immoral and may have been punished under other laws (similar to how the Church would punish girls for being "tomboys") as lesbians were previously punished by law in the 17th century and prior.Duberman 1989, p.349. Those convicted of a voluntary act were sent into exile for 4–5 years, and for a violent act - for 12. However, there were practically no lawsuits, in fact, this law was "dead", the persecution of homosexuals in Russia was less than in the rest of Europe. In the second half of the 19th century and the beginning of the 20th, there was a legal relaxation of penalties for homosexuality.

Author and critic Konstantin Leontiev was bisexual and one of the most famous couples in the late 19th century Russian literary world were the lesbians Anna Yevreinova (a lawyer) and Maria Feodorova (an author). Another notable Russian lesbian couple were poet Polyxena Solovyova and Natalia Manaseina.Duberman 1989, p.351. Other notables included poet Alexei Apukhtin, Pyotr Tchaikovsky, conservative author and publisher Prince Vladimir Meshchersky, Sergei Diaghilev, who had an affair with his cousin Dmitry Filosofov and after the breakup with Vaslav Nijinsky. Mikhail Kuzmin's novel Wings (1906) became one of the first "coming out" stories to have a happy ending and his private journals provide a detailed view of a gay subculture, involving men of all classes.

While there was a degree of government tolerance extended to certain gay or bisexual artists and intellectuals, especially if they were on friendly terms with the Imperial family, the pervasive public opinion, greatly influenced by the Eastern Orthodox Church, was that homosexuality was a sign of corruption, decadence and immorality. Russian author Alexander Amfiteatrov's novel titled People of the 1890s (1910), reflected this prejudice with two gay characters: a masculine lesbian attorney and a decadent gay poet. Leo Tolstoy's Resurrection introduces a Russian artist, convicted for having sex with his students, but given a lenient sentence; and a Russian activist for gay rights as examples of the widespread corruption and immorality in Tsarist Russia.

Russian urbanization had helped to ensure that Saint-Petersburg and Moscow both had gay brothels, along with many public places where men would buy and sell sexual services for or from other men. While there certainly was lesbian prostitution and some alleged lesbian affairs, less was publicly said, good or bad, about gay or bisexual women. Grand Duke Sergei Alexandrovich Romanov (the younger brother and uncle, respectively, of Russian Emperors Alexander III and Nicholas II) served as the governor of Moscow from 1891 to 1905. His homosexual relationships were widely famous in Moscow. In general, the experience of the Russian Empire shows that Russians were often more humane and tolerant of homosexuality than other Europeans. Development of homophobia began later, with the October Revolution and the establishment of Bolshevik power.

Anarchists and Kadets Anarchist Alexander Berkman softened his prejudice against homosexuality through his relationship with Emma Goldman and his time spent in jail, where he learned that working-class men could be gay, thus debunking the idea that homosexuality was a sign of upper middle class or wealthy exploitation or decadence.Duberman 1989, p.353.

One of the founders of the Kadets party, Vladimir Dmitrievich Nabokov, had written a research paper on the legal status of homosexuality in Russia, published by early gay rights advocate Dr. Magnus Hirschfeld in Berlin. In addition to the legal research, the paper argued that the anti-gay criminal law should be repealed, making him the first Russian politician to publicly express support for gay rights.

Soviet Union

LGBT history after the October Revolution: 1917–1933 The Soviet government of the Russian Soviet Republic (RSFSR) decriminalised homosexuality in December 1917, following the October Revolution and the discarding of the Legal Code of Tsarist Russia.Russia Under the Bolshevik Regime. E. H. Carr. 1994.

The legalisation of homosexuality was confirmed in the RSFSR Penal Code of 1922, and following its redrafting in 1926. According to Dan Healey, archival material that became widely available following the collapse of the Soviet Union in 1991 "demonstrates a principled intent to decriminalize the act between consenting adults, expressed from the earliest efforts to write a socialist criminal code in 1918 to the eventual adoption of legislation in 1922."Dan Healey, Homosexual Desire in Revolutionary Russia, 2001

The legalisation of private, adult and consensual homosexual relations only applied to the Russian SFSR and the Ukrainian SSR. Homosexuality or sodomy remained a crime in the Azerbaijan SSR (officially criminalised in 1923) as well as in the Transcaucasian and Central Asian Soviet Republics throughout the 1920s.Healey, Dan. "Masculine purity and 'Gentlemen's Mischief': Sexual Exchange and Prostitution between Russian Men, 1861–1941". Slavic Review. Vol. 60, No. 2 (Summer 2001), p. 258. Similar criminal laws were enacted in the Uzbek SSR in 1926 and in the Turkmen SSR the following year.Dan Healey GLQ 8:3 Homosexual Existence and Existing Socialism New Light on the Repression of Male Homosexuality in Stalin's Russia pp. 349–378 2002