The Russian Soviet Federative Socialist Republic (Russian SFSR), previously known as the Russian Socialist Federative Soviet Republic (RSFSR) and the Russian Soviet Republic, and unofficially as Soviet Russia, was a communist state from 1917 to 1922, and afterwards the largest and most populous constituent republic of the Soviet Union (USSR) from 1922 to 1991, until becoming a sovereign part of the Soviet Union with priority of Russian laws over Union-level legislation in 1990 and 1991, the last two years of the existence of the USSR. The Russian SFSR was composed of sixteen smaller constituent units of autonomous republics, five autonomous oblasts, ten autonomous okrugs, six krais and forty oblasts. Russians formed the largest ethnic group. The capital of the Russian SFSR and the USSR as a whole was Moscow and the other major urban centers included Leningrad (Petrograd until 1924), Stalingrad (Volgograd after 1961), Novosibirsk, Sverdlovsk, Gorky and Kuybyshev.
On 7 November 1917 [O.S. 25 October], as a result of the October Revolution, the Russian Soviet Republic was proclaimed as a sovereign state and the world's first communist state guided by communist ideology. The first constitution was adopted in 1918. In 1922, the Russian SFSR signed a treaty officially creating the USSR. On 12 June 1990, the Congress of People's Deputies adopted the Declaration of State Sovereignty. On 12 June 1991, Boris Yeltsin, supported by the Democratic Russia pro-reform movement, was elected the first and only President of the RSFSR, a post that would later become the Presidency of the Russian Federation. The August 1991 Soviet coup d'état attempt in Moscow with the temporary brief internment of President Mikhail Gorbachev destabilised the Soviet Union. Following these events, Gorbachev lost all his remaining power, with Yeltsin superseding him as the pre-eminent figure in the country. On 8 December 1991, the heads of Russia, Ukraine and Belarus signed the Belovezha Accords declaring dissolution of the USSR and established the Commonwealth of Independent States (CIS) as a loose replacement confederation. On 12 December, the agreement was ratified by the Supreme Soviet (the parliament of the Russian SFSR); therefore the Russian SFSR had renounced the Treaty on the Creation of the USSR and de facto declared Russia's independence from the USSR itself and the ties with the other Soviet republics.