In Germany, he conducted studies at the German General Staff and on the fronts of the German Army. In 1918, after the signing of the Armistice of Mudros following the end of World War I, Atatürk returned to Istanbul from his post in Syria.
Secretly, he began preparing for the liberation of the country, taking up the post of Inspector of Armies.
The Turkish Grand National Assembly (TBMM) began its historic session in Ankara on April 23, 1920, thanks to Atatürk's efforts, and he was elected as its President and the Head of Government.
Atatürk declared to the world that the Turkish nation rejected the Treaty of Sèvres signed between the Ottoman government and the Allied Powers.
In 1921, the Greek forces, who had invaded İzmir with the support of the Allied Powers, were halted by Turkish forces in the First and Second Battles of İnönü.
The Greek army, which attacked again in August 1921, was decisively defeated in the Battle of Sakarya, where the Turkish army, led by Atatürk, emerged victorious after 22 days of intense fighting.
On August 26, 1922, the Turkish Army launched a counter-offensive to liberate the homeland from foreign occupation.
This victory led to Atatürk being awarded the rank of Marshal and the title "Gazi" (Veteran) by the Grand National Assembly.
On August 30, 1922, in the Battle of Dumlupınar, the Turkish forces, commanded by Atatürk, decisively destroyed the majority of the Greek army.
The Turkish army pursued the retreating enemy forces and entered İzmir on September 9, 1922. On October 11, 1922, the Armistice of Mudanya was signed, and the Allied forces withdrew from the Turkish territories they had occupied.
After the War of Independence, on October 29, 1923, the Republic of Türkiye was declared, and Atatürk was elected its first President.
He was re-elected four times and served as the longest-serving president until his death in 1938.