The Russian Empire entered World War I in alliance with Serbia, which had been attacked by Austria-Hungary. It did not survive that war. By early 1917, the Czar had abdicated and by the end of that year, the Empire was replaced by a Socialist Republic.
Internal disorder led to a hastily negotiated agreement with Germany at Brest-Litovsk in March 1918. However, the following collapse of the German Empire and the civil war that was ongoing between the Bolsheviks and White Russians led to more conflict and territorial losses. Poland, Finland, the three Baltic States, Ukraine and Byelorussia all declared independence from Russia. Romania and Turkey both took some previously held Russian territories. Poland engaged in a war where it conquered vast territories East of the previously Russian-dominated Congress Poland.
When the Peace of Riga was signed in March 1921, Russia had lost considerable territory in the West. The creation of the Soviet Union in 1922 re-established the union of previous nationalities of the Russian Empire with the Russian Federative Republic, and the situation remained stable until 1939.