At the start of World War I, when the German troops occupied the Western part of Latvia, Latvians signed up with the newly created Battalion of Latvian Riflemen in a surge of patriotism. After the February Revolution, on 5 July 1917 the Russian Provisional Government granted autonomy rights to the Provinces of Vidzeme and Kurzeme which were already self-governed by the Land Boards of Vidzeme and Kurzeme elected at an earlier time.
More than 500 Latvian factories with all of their technical equipment were evacuated from Latvia to Russia to protect them.
As a result of the failed military campaigns of the Tsar's army, Latvian support for the Bolsheviks grew in the wake of the October Revolution of 1917, in the hope for 'a free Latvia in a free Russia’, which led to the formation of an autonomous Soviet Latvia in the Russian-controlled territories of Vidzeme and Latgale.
On 3 September 1917, German troops occupied Riga, and on 30 November the Latvian National Council, which was formed on 16 November 1917, declared Latvian autonomy. On 30 January 1918 the Council declared that Latvia should be an independent, democratic republic uniting Kurzeme, Vidzeme, and Latgale. According to the Treaty of Brest-Litovsk of 3 March 1918, Soviet Russia renounced territorial claims in Latvia (except for Latgale). A United Baltic Duchy was created in the lands of Estonia and Latvia occupied by Germany.