His involvement in early revolutionary activity against Tsarist Russia had led to his imprisonment. In World War I he raised three Polish legions to fight Russia, but German refusal to guarantee the ultimate independence of Poland led him to withdraw his support of Germany. After the war, Poland was declared independent with Piłsudski as Chief of State (1918–22) and Chief of the Army Staff (1918–27). He successfully commanded the Poles in the war against the Bolsheviks (1920–21). In 1926, after a military revolt, he assumed the office of Minister of Defence, establishing a virtual dictatorship, and tried to guarantee Poland’s independence by signing non-aggression pacts with Germany and the Soviet Union in 1934. He died in office.