Large numbers of Czechs and Slovaks defected on the Russian front and formed the Czechoslovak Legion, organised by Milan Rastislav Stefanik (a Slovak astronomer and general of the French army). Masaryk went to western Europe and began propagating the idea that the Austro-Hungarian Empire should be dismembered and that Czechoslovakia should be an independent state.
In 1916, together with Edvard Benes and Milan Rastislav Stefanik, Masaryk created the Czechoslovak National Council. Masaryk in the United States, Štefánik in France, and Beneš in France and Britain then worked to gain Allied recognition. When secret talks between the Allies and Austrian emperor Charles I collapsed, the Allies recognised the Czechoslovak National Council in the summer of 1918 as the supreme organ of a future Czechoslovak government.
On May 31, 1918, Czech and Slovak representatives in the United States signed the Pittsburgh Agreement endorsing a plan for a unified Czechoslovak state in which Slovakia would have its own assembly. In early October 1918, Germany and Austria proposed peace negotiations. On October 18, 1918 , while in the United States, Masaryk issued a declaration of Czechoslovak independence. Masaryk insisted that the new Czechoslovak state include the historic Bohemian Kingdom, containing the German-populated borderland. On October 21, however, German deputies from Bohemia joined other German and Austrian deputies in the Austrian parliament in declaring an independent German-Austrian state. Following the abdication of Charles I on November 11, Czech troops took control of borderlands. Just days after on October 30, 1918 in Martin, a creation of SNR (Slovak National Assembly) and establishment of the declaration of Slovak nation has taken place.
Hungary withdrew from the Habsburg empire on November 1. The new liberal-democratic government of Hungary attempted to retain Slovakia. With Allied approval, the Czechs occupied Slovakia, and the Hungarians were forced to withdraw. The Czechs and Allies agreed on the Danube and Ipel rivers as the boundary between Hungary and Slovakia; a large Hungarian minority, occupying the fertile plain of the Danube, would be included in the new state.