Upon the declaration of Latvian independence on 18 November 1918, a provisional government was formed, led by K. Ulmanis; however, the real power was still in the hands of the German occupation authorities which continued to believe that, from the perspective of international law, the Treaty of Brest-Litovsk whereby Russia had renounced its claims on the Baltic countries and had ceded them to Germany, was still in force.
The Red Army of Soviet Russia started an intervention in the Baltic countries soon after the German defeat in World War I and the signature of the Compiegne Armistice. Thus the Latvian freedom fights started on 1 December. Since the Latvian government had not yet managed to create an army capable of fighting, the Bolsheviks quickly occupied almost the entire Latvian territory, with the exception of the counties of Liepaja, Grobina, and Aizpute. The Latvian Soviet Socialist Republic, managed by the government of P. Stucka, was established with the support of Soviet Russia in Latvia in December 1918.
In turn, the German Army Command in Liepaja under the leadership of General Rüdiger von der Goltz planned to establish a state in the territory of Latvia with a pro-German government with a disproportionately large representation of the Baltic Germans in it. Therefore it organised a coup on 16 April 1919 which led to the formation of a provisional government of Latvia headed by A. Niedra. The other provisional government led by K. Ulmanis took refuge aboard the ship Saratov which was guarded by warships of the Entente Powers and lay in the Port of Liepaja.
The Southern Brigade of the Latvian Army, the Baltic Landeswehr, a troop of German and Russian mercenaries (the Iron Division and other units) started a counterattack on the army of the Latvian Socialist Soviet Republic (LSSR) in March 1919 and took Riga on 22 May. Further progress of the pro-German forces in Vidzeme was directed against the Northern Latvian Army loyal to the government of K. Ulmanis and the Estonian troops, the latter of which had fought back Northern Vidzeme from the Bolsheviks and had just taken the town of Cesis. After bitter fights from 19 to 23 June the Estonians and the Latvians managed to defeat the Germans and force them to retreat towards Riga. The Armistice of Strazdumuiza was signed with the mediation of the allies according to which the German troops had to leave Latvia, the Landeswehr was sent to the front in Latgale to fight against the Bolsheviks, A. Niedra’s government ceased to exist, and the government of K. Ulmanis could return to Riga.
However, Rüdiger von der Goltz still had not abandoned his goals, and in autumn 1919 the troops of German and Russian mercenaries were included in the Western Russian Army of Volunteers headed by Colonel Bermont –Avalov. In early October the Bermont’s army set out from Jelgava to attack Riga but was only able to take the area of Pardaugava. In early November, with the support of warships of the allies, Latvians managed to fight back the area of Bolderaja, then the entire area of Pardaugava, and to drive away the Western Russian army commanded by Bermont from Latvia.
By the end of January 1920 the Army of the Republic of Latvia had succeeded in driving away the Bolsheviks from Latgale too, and the fights for freedom had thus come to an end. A peace treaty was signed with Soviet Russia on 11 August 1920; according to Article 2 of the Treaty, ‘Russia unconditionally recognizes the national independence, autonomy and sovereignty of the State of Latvia, and voluntarily and forever renounces all sovereign rights held by Russia in the people and land of Latvia...’