After World War I and during the gradual break-up of Austria-Hungary, the city at first became a part of the transient "Eastern Slovak Republic", declared on December 11, 1918, in Košice and earlier in Prešov under the protection of Hungary. On December 29, 1918, the Czechoslovak Legions entered the city, making it part of the newly established Czechoslovakia. However, in June 1919, Košice was occupied again, as part of the Slovak Soviet Republic, a proletarian puppet state of Hungary. The Czechoslovak troops secured the city for Czechoslovakia in July 1919, which was later upheld under the terms of the Treaty of Trianon in 1920.