After the October Revolution, many governments were formed in the Ukrainian lands. The two most important of them were Lviv-based Ukrainian People's Republic in west and Kharkiv-based Ukrainian People's Republic of Soviets in east. These two sides were in permanent conflict between each other, which resulted in many casualties among Ukrainians fighting in opposition in civil war as part of the wider Ukrainian-Soviet War.
Following the Peace of Lviv in 1921, the Ukrainian People's Republic was recognized as a legal government in western Ukraine although was immediately subjugated by Poland within a military and semi-political union called Międzymorze. On other hand, Soviet Russia would extend control over eastern Ukraine what would ultimately become the Ukrainian Soviet Socialist Republic and a member of the Soviet Union in 1922. Between 1921 and 1939, the Ukrainian People's Republic was officialy recognized by most of world nations as the sole representative of Ukrainian nation and joined the League of Nations in 1922.
At the start of World War II, the Ukrainian People's Republic was invaded by the Red Army following the German invasion of Poland. For a year, the Soviets maintained the military occupation in western Ukraine while oversaw the Sovietization process. In 1940, the Soviets staged a heavily rigged parliamentary election in the Ukraine in order to legitimize the annexation of the Ukrainian People's Republic into Soviet Ukraine. The pro-Soviet Ukrainian People's Council then voted for western Ukraine to join already-existing Ukrainian Soviet Socialist Republic, thus united the Ukraine under the Soviet Union.
At the onset of German invasion of the Soviet Union in 1941, the government of the Ukrainian People's Republic was briefly reinstated by the Germans with a claimed control over all Ukrainian lands despite only nominally controlled Lviv and surrounding areas. The UPR government also formally entered the Axis powers by signing the Tripartite Pact in 1942. After the Red Army entered Lviv in 1944, the Ukrainian People's Republic was formally dissolved as whole Ukraine was now under control of internationally-recognized Ukranian Soviet Socialist Republic which was within the Union of Soviet Socialist Republics.