Until the end of the First World War, the territory of modern Ukraine was divided between Austria-Hungary and the Russian Empire. During the 19th century the Ukrainians were generally referred to as Ruthenians, but as their national and political consciousness grew, they preferred to call themselves Ukrainians.
During World War I, the Russian and Austro-Hungarian empires started to collapse. From Wikipedia:
During 1917–20, several separate Ukrainian states briefly emerged: the Ukrainian People's Republic, the Hetmanate, the Directorate and the pro-Bolshevik Ukrainian Soviet Socialist Republic (or Soviet Ukraine) successively established territories in the former Russian Empire; while the West Ukrainian People's Republic and the Hutsul Republic emerged briefly in the former Austro-Hungarian territory. However, Poland defeated Western Ukraine in the Polish-Ukrainian War, but failed against the Bolsheviks in an offensive against Kiev.
According to the Peace of Riga concluded between the Soviets and Poland, western Ukraine was officially incorporated into Poland, who in turn recognised the Ukrainian Soviet Socialist Republic in March 1919. The war in Ukraine continued for another two years; by 1921, however, most of Ukraine had been taken over by the Soviet Union, while Galicia and Volhynia were incorporated into independent Poland. Ukraine became a founding member of the Union of Soviet Socialist Republics or the Soviet Union in December 1922.