The oldest settlement on the site belonged to the Hatti, a Bronze Age people, and the Hittites followed in the 2nd millennium BC. The place grew into a real city under the Phrygians from about 1000 BC, when people moved here from their capital Gordion after an earthquake damaged it. Alexander the Great came through in 333 BC. Greeks from Pontos then built it up as a trading post, and they gave it the name Ankyra, "anchor", which Turks still use in a slightly worn form.
In 278 BC Celtic-speaking Galatians took over central Anatolia and made Ankara a tribal headquarters. St. Jerome, who knew Galatia, wrote around 400 that the speech near Ankara sounded like that of Trier, far to the northwest. Augustus took the city in 25 BC and made it a provincial capital, and it grew into a metropolis of perhaps 200,000 in good times. No later century until the 20th matched that. The Roman baths, built around 200 AD and used for 500 years, still lie open in the old town.
Ancyra mattered because the main roads of northern Anatolia crossed here. That helped trade and armies, and invaders used the same roads: Goths and then Arabs came through in the 3rd century. In 314 the city hosted an important council of the early church. Later, emperors based in Constantinople escaped the damp summers on the Bosphorus for the drier air here, and Theodosius II held his summer court in Ancyra.
The Seljuk sultan Alparslan won the Battle of Manzikert in 1071 and took Ankara two years later. Orhan, an early Ottoman ruler, captured it in 1356. In 1402 Timur beat the Ottomans in a battle outside the city and took it, though by 1403 it was Ottoman again, and it stayed so for about 500 years. Sultan Alaeddin Mosque, from 1178, is the oldest mosque you can visit. Arslanhane Mosque, built in 1290 in Seljuk style, is one of five wooden mosques in Central Anatolia that UNESCO listed in 2023.
Before 1923 Ankara was a provincial town with under 30,000 people. After the Ottoman defeat in the First World War and the Allied occupation of Constantinople, Atatürk's nationalists set up their headquarters here in 1920. On 13 October 1923 Ankara replaced Constantinople as capital. Look at the Victory Monument in Ulus Square, put up in 1927: it is one of the few republican monuments still inscribed in Ottoman Turkish, in Arabic script, because the alphabet reform came a year later.
The new capital split into an old section, Ulus, and a new one, Yenişehir, now centred on Kızılay. Growth at first followed the plan. From the 1950s it ran far ahead, as people left the countryside for work and built unlicensed houses called gecekondu on the edges. Many have since been replaced by tower-block estates such as Eryaman and Güzelkent. In 2022 the city had almost 5.2 million people, second only to Istanbul. The president moved in 2018 to the Ak Palace, 10 km north of Çankaya.