After the Treaty of Berlin in 1878, Austria-Hungary stationed military garrisons in the Ottoman Vilayet of Bosnia and Ottoman Sanjak of Novi Pazar, which formally (de jure) continued to be Ottoman territories. Taking advantage of the chaos that occurred during the Young Turk Revolution in 1908, Bulgaria declared its formal independence on 5 October 1908. The following day, Austria-Hungary unilaterally annexed Bosnia on 6 October 1908, but pulled its military forces out of Novi Pazar in order to reach a compromise with the Ottoman government and avoid a war (the Ottoman Empire lost the Sanjak of Novi Pazar with the Balkan Wars of 1912–1913.)