Tehran is the capital of Iran and Tehran Province. With a population of around 9 million in the city and 16 million in the wider metropolitan area, Tehran is the largest city and urban area of Iran, the 2nd-largest city in Western Asia, and the 3rd-largest 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 present-day city of Tehran was occupied by a Median city which in the Avesta occurs as Rhaga. It was destroyed by the Mongols in the early 13th century, and remains now as a city in Tehran Province, located towards the southern end of the modern-day city of 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-Persian 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.