After 2000 BCE, successive waves of semi-nomadic people from Central Asia began moving south into Afghanistan; among them were many Indo-European-speaking Indo-Iranians, who later migrated further into South Asia, Western Asia, and to the areas around the Caspian Sea. At the time, the region was referred to as Ariana. The religion Zoroastrianism is believed by some to have originated in what is now Afghanistan between 1800 and 800 BCE, as its founder Zoroaster is thought to have lived and died in Balkh. An inscription on the tombstone of Darius I of Persia mentions the Kabul Valley in a list of the 29 countries that he had conquered. Alexander the Great and his Macedonian forces arrived to Afghanistan in 330 BCE after defeating Darius III of Persia only a few years earlier. The successor state of the Seleucid Empire controlled the region until 305 BCE, when they gave much of it to the Maurya Empire as a part of an alliance treaty. Mauryans controlled the area south of the Hindu Kush until they were overthrown in about 185 BCE. Arab Muslims brought Islam to Herat and Zaranj in 642 CE, later spreading eastwards. Some native Afghans accepted the Arab invasion, though numerous others rebelled against the Muslims. The land was collectively recognized by the Arabs as al-Hind due to its cultural connection with Greater India. Before the rise of Islam, most of the people in the region of modern-day Afghanistan were Buddhists and Zoroastrians. It is reported that Muslims and non-Muslims still lived side by side in Kabul before the Ghaznavids rose to power in the 10th century. By the 11th century, Mahmud of Ghazni defeated the remaining Hindu rulers and Islamized parts of Greater Afghanistan. Afghanistan was one of the main centers of the Muslim world during the Islamic Golden Age. In 1219 CE, Genghis Khan and his Mongol army overran the region. His troops are said to have annihilated the Khorasanian cities of Herat and Balkh.
After the conquest of Afghanistan, and even after the fall of the Mongol Empire, Afghanistan was still ruled by ethnic Mongol states, including the Ilkhanate and the Timurids. Indian dynasties still ruled over the southwest areas of Afghanistan, though these were also conquered by the Timurids. In the early 16th century, Babur arrived from Fergana and captured Kabul from the Arghun dynasty. In 1526, he invaded Delhi in India to replace the Lodi dynasty with the Mughal Empire. This empire would go on to become the most powerful state in all of India until its collapse in the mid-18th century. During this timespan, parts of Afghanistan were also ruled by Persians and Bukharans. Before the 19th century, the northwestern area of Afghanistan was referred to by the regional name Khorasan. The regions of Kandahar, Zabulistan, Ghazni, Kabulistan, and Afghanistan formed the frontier between Khorasan and Hindustan. In 1709, Mirwais Hotak, a local Ghilzai tribal leader, successfully rebelled against the Safavids. He defeated Gurgin Khan of Persian and made Afghanistan an independent state. Mahmud, Mirwais's successor, conquered the Persian capital of Isfahan, captured the city after the Battle of Gulnabad and proclaimed himself King of Persia, though these claims weren't legitimate and he was ousted from Persia shortly after. The Afghan Empire came under threat in the early 19th century because of the surrounding Persians in the west and the British-backed Sikhs in the east. During the late 1800s, Afghanistan would become a British protectorate, though they enjoyed nominal independence.
After the Third Anglo-Afghan War and the signing of the Treaty of Rawalpindi in 1919, King Amanullah Khan declared Afghanistan a sovereign and fully independent state. He moved to end his country's traditional isolation by establishing diplomatic relations with the international community. He decided to help modernize Afghanistan, introducing several reforms, some of which are the banning of slavery and compulsory elementary education. Some of the reforms that were actually put in place, such as the abolition of the traditional burqa for women and the opening of a number of co-educational schools, quickly alienated many tribal and religious leaders. Due to overwhelming opposition, Amanullah was forced to abdicate after rebel forces took Kabul. King Nadir Shah was implemented onto the throne, who abandoned the reforms and tried to slow the approach to modernization but was assassinated in 1933 by Abdul Hazara. Mohammed Zahir Shah, Nadir Shah's 19-year-old son, succeeded to the throne and reigned from 1933 to his death in 2007. After he died, his son, Ahmad Shah Khan took the throne.