Tehran is the capital of Iran and Tehran Province. With a population of around 8.8 million in the city and 15 million in its larger metropolitan area, Tehran is the most populous city in Iran and Western Asia, and it has the second-largest metropolitan area in the Middle East. It is ranked 29th in the world by the population of its metropolitan area.In the Classical era, part of the territory of present-day Tehran was occupied by Rhages, a prominent Median city. It was subject to destruction following the Arab, Turkic, and Mongol invasions. Its modern-day inheritor remains as an urban area absorbed into the metropolitan area of Greater Tehran.Tehran was first chosen as the capital of Iran by Agha Mohammad Khan of the Qajar dynasty in 1796, in order to remain within close reach of Iran's territories in the Caucasus, before being separated from Iran as a result of the Russo-Iranian Wars, and to avoid the vying factions of the previously ruling Iranian dynasties. The capital has been moved several times throughout the history, and Tehran is the 32nd national capital of Iran.