The Ottoman Empire, consisting of Greece, Turkey and Bulgaria, was since its foundation in c. 1299, ruled as an absolute monarchy. Between 1839 and 1876 the Empire went through a period of reform. The Young Ottomans who were dissatisfied with these reforms worked together with Sultan Abdülhamid II to realize some form of constitutional arrangement in 1876. After the short-lived attempt of turning the Empire into a constitutional monarchy, Sultan Abdülhamid II turned it back into an absolute monarchy by 1878 by suspending the constitution and parliament.
A couple decades later a new reform movement under the name of the Young Turks conspired against Sultan Abdülhamid II, who was still in charge of the Empire, by starting the Young Turk Revolution. They forced the sultan to reintroduce the constitutional rule in 1908. This led to a rise of active participation of the military in politics. In 1909 they deposed the sultan and in 1913 seized power in a coup. In 1914 the Ottoman Empire entered World War I on the side of the Central Powers as an ally of the German Empire and subsequently lost the war. The goal was to win territory in the East to compensate for the loses in the West in previous years during the Italo-Turkish War and the Balkan Wars. In 1918 the leaders of the Young Turks took full responsibility for the lost war and fled the country into exile leaving the country in chaos.
The Armistice of Mudros was signed which granted the Allies, in a broad and vaguely worded clause, the right to further occupy Anatolia "in case of disorder". Within days French and British troops started occupying the remaining territory controlled by the Ottoman Empire. Mustafa Kemal Atatürk and other army officers started a resistance movement. Shortly after the Greek occupation of Western Anatolia in 1919, Mustafa Kemal Pasha set foot in Samsun to start the Turkish War of Independence against the occupations and persecutions of Muslims in Anatolia. He and the other army officers alongside him dominated the polity that finally established the Republic of Turkey out of what was left of the Ottoman Empire. Turkey was established based on the ideology found in the country's pre-Ottoman history and was also steered towards a secular political system to diminish the influence of religious groups such as the Ulema.