Prior to the First World War, Sikorski established and participated in several underground organizations that promoted the cause of the independence of Poland from the Russian Empire. He fought with distinction in the Polish Legions during the First World War, and later in the newly created Polish Army during the Polish–Soviet War of 1919 to 1921. In that war, he played a prominent role in the decisive Battle of Warsaw (1920). In the early years of the Second Polish Republic, Sikorski held government posts, including serving as Prime Minister (1922 to 1923) and as Minister of Military Affairs (1923 to 1924). Following Józef Piłsudski's May Coup of 1926 and the installation of the "Sanation" government, he fell out of favor with the new régime.