When the war ended the Western powers, while still not recognizing the Soviet takeover of the Baltics, allowed Stalin to keep them to preserve the peace, and the USSR began another wave of deportations, targeting not only Nazi collaborators but also farmers and people that lived in rural areas. The reason that these people were targeted was because they were helping and supplying rebel groups that were fighting a guerrilla war against the Soviet army, but despite the deportations the partisans continued fighting until 1956, when the majority lost the will to fight after witnessing how the Soviets crushed the attempted uprising in Hungary, and how the West did nothing to help. The largest of the deportations was carried out from the 24th to the 28th of March, 1949, when 42,133 people were sent to Siberia. They made up 2% of the pre-WWII population of Latvia.
The 1949 Deportations (Source: guardianlv.com)
Along with the deportations the Soviet authorities converted Latvia from a capitalist democracy to a communist state by implementing policies such as the collectivization of farms, which only made the destruction WWII had caused worst. At the same time as ethnic Latvians were being deported in large numbers, massive amounts of immigrants were brought in from other parts of the USSR, reducing the ethnic Latvian population from roughly 75% of the country to barely more than 50%. These immigrants were mostly Russian, as the Soviet government had a policy of aggressive Russification all throughout the Baltics, as Russian became the main language for all government affairs, and it was taught in schools instead of Latvian. However things began to change in Latvia, and the rest of the USSR, in the 1980s after Mikhail Gorbachev became the General Secretary of the Communist Party in 1985 and tried to modernize the Soviet Union by implementing Glasnost and Perestroika, encouraging free speech and business in the Soviet Union.
With the rights to free speech that Glasnost promised, Latvians and other people across the USSR started demanding independence, and the USSR and its satellite states began to crumble. The Latvian government adopted a new Declaration of Independence on the 4th of May 1990. Gorbachev, however, refused to recognize Latvia’s independence. The next year, from the 19th to the 21st of August, 1991, there was a crisis in Moscow, as a group of Soviet government members attempted to plot a coup and overthrow Gorbachev, but they were stopped by Boris Yeltsin, who became the president of the independent Russian Federation, and the USSR recognized Latvia’s independence on September 6th,1991, after 46 years of occupation.
Boris Yeltsin (left with his fist raised) during the attempted coup in 1991 (Source: The Economist)