Istanbul, formerly known as Konstantiniyye, is the most populous city in Turkey and the country's economic, cultural, and historic center; Ankara is the capital. Located on both sides of the Bosporus in both Europe and Asia, it was founded by the Greeks as Constantinople, but, following the fall of Constantinople to the Ottoman Turks in 1453, it was resettled with Muslims, Jews, and Christians from other parts of Anatolia, as well as by returning refugees from the siege. By September 1453, he had transferred 5,000 households, including those of prisoners of war and deported people, to his new capital, which he renamed to "Istanbul"; in 1459, the deported Greeks returned. Despite being eternally plagued by sickness, Istanbul became a cosmopolitan city whose population was frequently replaced by new migrants and immigrants, and the city's population averaged around 500,000 until the start of the 19th century. Sultan Mehmed the Conqueror went on to build the Grand Bazaar and Topkapi Palace, and, under his successors, the city was transformed from a Greek Christian city to an Islamic one.
When the Ottoman Empire claimed to be a caliphate in 1517, Istanbul became the capital of the last universally recognized caliphate. During the Tanzimat reforms of the 19th century, new technology was introduced to Istanbul, and bridges across the Golden Horn were built and Istanbul was connected to the rest of Europe's large cities by railroad during the 1880s. In addition, a modern water supply network, electricity, telephones, and trams were introduced to the city. However, World War I ended the city's cosmopolitan status, as, on 24 April 1915, the Ottomans deported the Armenian intellectual community at the start of what would become the Armenian Genocide, and the Christian population declined from 450,000 in 1914 to 240,000 in 1927. In 1923, the new Turkish republic moved the capital to Ankara, distancing the new secular republic from its Ottoman history. In 1926, the city was formally renamed Istanbul, and "Constantinople" was not recognized by the post office from that year on, in a move to shed the city's Ottoman past.
During the 1970s, industrialization led to an influx of rural Turks seeking factory jobs, and the city expanded into the previously outlying villages and forests. By 2019, the Istanbul megacity had a population of 15,519,267 people, the vast majority of whom were Sunni Muslims. Between 5% and 15% of Istanbul's population was irreligious, while the city also had small Greek, Italian, and Armenian communities. As of 2020, Istanbul has voted for the winning party in every general election since 1995, and, from 1994 to 2019, Istanbul was ruled by a string of conservative mayors, including AKP leader Recep Tayyip Erdogan. Starting in the 2010s, Istanbul and many of Turkey's metropolitan cities began moving away from the AKP government and its right-wing ideology, and, in 2019, the social democratic CHP mayoral candidate Ekrem Imamoglu won two mayoral elections, the second held after the first election was too close to call.