The Ottoman Empire had entered a state of decline late in the nineteench century that continued up until its final demise at the end of World War One.
The once mighty Empire had lost territory to invasions from Russia and Austria and also as the result of nationalist movements in the Balkans. Greece was among the first to gain its independence, and thereby sliced away a large portion of the Empire. Serbia, Romania and Bulgaria soon followed suit; all instituted by nationalist movements sweeping the Balkans. By the time World War One broke out, the Empire was known as the "Sick Old Man of Europe."
In an unfortunate development, the Empire had commissioned (and paid for) two warships from the British navy. When World War One broke out, the British First Lord of the Admiralty, Winston Churchill countermanded the order, seized the ships for the British navy, and kept the money. The Ottomans were so angered that this, along with other political developments, led them to join the Central Powers during the War. This proved to be the coup de grace of the Empire.
Ottoman forces were virtually destroyed by the Allied Powers, despite an Ottoman victory at Gallipoli. Mustapha Kemal, later known as Attaturk, gained tremendous political prestige during the War and was largely instrumental in the formation of modern Turkey.
The end came on October 30, 1918 when the Empire was forced to surrender to Allied forces. Afterwards, the Treaty of Serves formally dissolved the Empire on October 29, 1923. The Allies planned to occupy the Empire, but Kemal organized a fierce resistance. Eventually, the Republic of Turkey with a capital at Ankara was established and formally recognized by the Treaty of Lausanne.