Query: The Latvian Soviet Socialist Republic was a republic of the Soviet Union in 2012.

Relevant passages:
Latvian Soviet Socialist Republic <=SEP=> The Latvian Soviet Socialist Republic ( Latvian SSR ; Latvijas Padomju Sociālistiskā Republika Латвийская Советская Социалистическая Республика , Latviyskaya Sovetskaya Sotsialisticheskaya Respublika ) , also known as Soviet Latvia or Latvia , was a republic of the Soviet Union .   It was established on 21 July 1940 , during World War II , as a Soviet puppet state in the territory of the previously independent Republic of Latvia after it had been occupied on June 17 , 1940 by the Soviet Army , in conformity with the terms of the 23 August 1939 Molotov -- Ribbentrop Pact .   Following the Welles Declaration of July 23 , 1940 , the annexation of Latvia into the Soviet Union ( USSR ) on 5 August 1940 was not recognized as legitimate by the United States , the European Community , and recognition of it as the nominal fifteenth constituent republic of the USSR was withheld for five decades . Its territory was subsequently conquered by Nazi Germany in June -- July 1941 , before being retaken by the Soviets in 1944 -- 1945 . Nevertheless , Latvia continued to exist as an de jure independent country with a number of countries continued to recognize Latvian diplomats and consuls who still functioned in the name of their former governments .   Soviet rule came to the end during the dissolution of the Soviet Union . The first freely elected parliament of the Latvian SSR passed a declaration `` On the Renewal of the Independence of the Republic of Latvia '' on May 4 , 1990 , restoring the official name of the State of Latvia as the Republic of Latvia . and restoring its former state symbols - flag and anthem . The full independence of the Republic of Latvia was restored on 21 August 1991 , during the 1991 Soviet coup d'état attempt and fully recognized by the Soviet Union on 6 September 1991 .

Dissolution of the Soviet Union <=SEP=> The Soviet Union was dissolved on December 26 , 1991 . It was a result of the declaration number 142-Н of the Soviet of the Republics of the Supreme Soviet of the Soviet Union . The declaration acknowledged the independence of the former Soviet republics and created the Commonwealth of Independent States ( CIS ) , although five of the signatories ratified it much later or did not do it at all . On the previous day , Soviet President Mikhail Gorbachev , the eighth and final leader of the Soviet Union , resigned , declared his office extinct , and handed over its powers -- including control of the Soviet nuclear missile launching codes -- to Russian President Boris Yeltsin . That evening at 7:32 , the Soviet flag was lowered from the Kremlin for the last time and replaced with the pre-revolutionary Russian flag .   Previously , from August to December , all the individual republics , including Russia itself , had seceded from the union . The week before the union 's formal dissolution , 11 republics signed the Alma-Ata Protocol formally establishing the CIS and declaring that the Soviet Union had ceased to exist . Both the Revolutions of 1989 and the dissolution of the USSR also signalled the end of the Cold War .   Several of the former Soviet republics have retained close links with the Russian Federation and formed multilateral organizations such as the Commonwealth of Independent States , Eurasian Economic Community , the Union State , the Eurasian Customs Union , and the Eurasian Economic Union to enhance economic and security cooperation . On the other hand , only the Baltic states have joined NATO and the European Union .