Following the outbreak of World War I, Sosnkowski participated in Piłsudski's formation of the Polish Legions. When the 1st Brigade of the legions was formed, Sosnkowski served as Pilsudski's chief of staff and second-in-command. He led troops at the Battle of Łowczówek and in several other encounters. On 10 May 1916 Sosnkowski became a colonel, and on 26 September of that year he took over the command of the 1st Brigade. During the Oath crisis, Piłsudski instructed the Polish Legion to refuse to swear an oath of allegiance to Kaiser Wilhelm II of Germany. Sosnkowski was arrested on 22 July 1917 and, along with his commander, imprisoned in Magdeburg. They were both freed on 8 November 1918, when the process of restoration of Poland's independence was nearly complete.