<P> In the early medieval period, the region's peoples resisted Christianisation and became subject to attack in the Northern Crusades . Latvia's capital city Riga, founded in 1201 by Germans at the mouth of the Daugava, became a strategic base in a papally - sanctioned conquest of the area by the Livonian Brothers of the Sword . It was to be the first major city of the southern Baltic and, after 1282, a principal trading centre in the Hanseatic League . </P> <P> By the 16th century, Baltic German dominance in Terra Mariana was increasingly challenged by other powers . Due to Latvia's strategic location and prosperous trading city of Riga, its territories were a frequent focal point for conflict and conquest between at least four major powers: the State of the Teutonic Order, the Polish--Lithuanian Commonwealth, Sweden and Russian Empire . The last period of external hegemony began in 1710, when control over Riga and parts of modern - day Latvia switched from Sweden to Russia during the Great Northern War . Under Russian control, Latvia was in the vanguard of industrialisation and the abolition of serfdom, so that by the end of the 19th century, it had become one of the most developed parts of the Russian Empire . The increasing social problems and rising discontent that this brought meant that Riga also played a leading role in the 1905 Russian Revolution . </P> <P> The First Latvian National Awakening began in the 1850s and continued to bear fruit after World War I when, after two years of struggle in the Latvian War of Independence, Latvia finally won sovereign independence, as recognised by Soviet Russia in 1920 and by the international community in 1921 . The Constitution of Latvia was adopted in 1922 . Political instability and effects of the Great Depression led to the May 15, 1934 coup d'état by Prime Minister Kārlis Ulmanis . Latvia's independence was interrupted in June--July 1940, when the country was occupied and incorporated into the Soviet Union . In 1941 it was invaded and occupied by Nazi Germany, then reconquered by the Soviets in 1944--45 . </P> <P> From the mid-1940s Latvian Soviet Socialist Republic was subject to Soviet economic control and saw considerable Russification of its peoples . However, Latvian culture and infrastructures survived and, during the period of Soviet liberalisation under Mikhail Gorbachev, Latvia once again took a path towards independence, eventually succeeding in August 1991 to be recognised by Russia the following month . Since then, under restored independence, Latvia has become a member of the United Nations, entered NATO and joined the European Union . </P>

When did latvia gain independence from the soviet union