Following the Ottoman defeat at World War I, the Ottoman capital Constantinople (modern Istanbul) and much of Anatolia were occupied by the Allies, who planned to share these lands between Armenia, France, Greece, Italy and the United Kingdom, leaving for the Turks the core piece of land in central Anatolia. In response, the leader of the Turkish nationalist movement, Mustafa Kemal Atatrk, established the headquarters of his resistance movement in Ankara in 1920. After the Turkish War of Independence was won and the Treaty of Svres was superseded by the Treaty of Lausanne, the Turkish nationalists replaced the Ottoman Empire with the Republic of Turkey on 29 October 1923. A few days earlier, Ankara had officially replaced Constantinople as the new Turkish capital city, on 13 October 1923.
After Ankara became the capital of the newly founded Republic of Turkey, new development divided the city into an old section, called Ulus, and a new section, called Yeniehir. Ancient buildings reflecting Roman, Byzantine, and Ottoman history and narrow winding streets mark the old section. The new section, now centered on Kzlay Square, has the trappings of a more modern city: wide streets, hotels, theaters, shopping malls, and high-rises. Government offices and foreign embassies are also located in the new section. Ankara has experienced a phenomenal growth since it was made Turkey's capital in 1923, when it was "a small town of no importance". In 1924, the year after the government had moved there, Ankara had about 35,000 residents. By 1927 there were 44,553 residents and by 1950 the population had grown to 286,781. Ankara continued to grow rapidly during the latter half of the 20th century and eventually outranked Izmir as Turkey's second largest city, after Istanbul. Ankara's urban population reached 4,587,558 in 2014, while the population of Ankara Province reached 5,150,072 in 2015.
The city is well known during the 4th century as a centre of Christian activity (see also below), due to frequent imperial visits, and through the letters of the pagan scholar Libanius. Bishop Marcellus of Ancyra and Basil of Ancyra were active in the theological controversies of their day, and the city was the site of no less than three church synods in 314, in 358, and in 375, the latter two in favour of Arianism. The city was visited by Emperor Constans I (r.337350) in 347 and 350, Julian (r.361363) during his Persian campaign in 362, and Julian's successor Jovian (r.363364) in winter 363/364 (he entered his consulship while in the city). After Jovian's death soon after, Valentinian I(r.364375) was acclaimed emperor at Ancyra, and in the next year his brother Valens(r.364378) used Ancyra as his base against the usurper Procopius. When the province of Galatia was divided sometime in 396/99, Ancyra remained the civil capital of Galatia I, as well as its ecclesiastical centre (metropolitan see). Emperor Arcadius (r.395408) frequently used the city as his summer residence, and some information about the ecclesiastical affairs of the city during the early 5th century is found in the works of Palladius of Galatia and Nilus of Galatia.
In 479, the rebel Marcian attacked the city, without being able to capture it. In 610/11, Comentiolus, brother of Emperor Phocas (r.602610), launched his own unsuccessful rebellion in the city against Heraclius (r.610641). Ten years later, in 620 or more likely 622, it was captured by the Sassanid Persians during the ByzantineSassanid War of 602628. Although the city returned to Byzantine hands after the end of the war, the Persian presence left traces in the city's archaeology, and likely began the process of its transformation from a late antique city to a medieval fortified settlement.
In 654, the city was captured for the first time by the Arabs of the Rashidun Caliphate, under Muawiyah, the future founder of the Umayyad Caliphate. At about the same time, the themes were established in Anatolia, and Ancyra became capital of the Opsician Theme, which was the largest and most important theme until it was split up under Emperor Constantine V (r.741775); Ancyra then became the capital of the new Bucellarian Theme. The city was attacked without success by Abbasid forces in 776 and in 798/99. In 805, Emperor Nikephoros I (r.802811) strengthened its fortifications, a fact which probably saved it from sack during the large-scale invasion of Anatolia by Caliph Harun al-Rashid in the next year. Arab sources report that Harun and his successor al-Ma'mun (r.813833) took the city, but this information is later invention. In 838, however, during the Amorium campaign, the armies of Caliph al-Mu'tasim (r.833842) converged and met at the city; abandoned by its inhabitants, Ancara was razed to the ground, before the Arab armies went on to besiege and destroy Amorium. In 859, Emperor Michael III (r.842867) came to the city during a campaign against the Arabs, and ordered its fortifications restored. In 872, the city was menaced, but not taken, by the Paulicians under Chrysocheir. The last Arab raid to reach the city was undertaken in 931, by the Abbasid governor of Tarsus, Thamal al-Dulafi, but the city again was not captured.