The history of Turkmenistan traditionally began with the arrival of Indo-European Iranian tribes around 2000 BC. Early tribes were nomadic or semi-nomadic due to the arid conditions of the region, preventing widespread adoption of agriculture. The steppe culture in Central Asia was an extension of a larger Eurasian series of horse cultures which spanned the entire spectrum of language families, including the Indo-Europeans and Turko-Mongol tradition groups. Some of the known early Iranian tribes included the Massagetae, the Scythians/Saka, and early Sogdia, who were most likely precursors of the Khwarazmians. Turkmenistan was a passing point for numerous migrations and invasions by tribes, which gravitated towards the settled regions of the south, including ancient Mesopotamia, Elam, and the Indus Valley Civilisation.

The region's written history begins with the region's conquest by the Achaemenid Empire of Ancient Iran, as the region was divided between the satraps of Margiana, Chorasmia and Parthia. Later conquerors included Alexander the Great, the Parni, Hephthalites, Iranian Huns, Göktürks, Sarmatians, and Sassanid Iranians. During this early phase of history, the majority of Turkmenistan's inhabitants were adherents of Zoroastrianism and Buddhism, and the region was largely dominated by Iranian peoples. These incursions and epochs, though pivotal, did not shape the region's history as the invasions of two later invading groups: Arabs and the Oghuz Turks. The vast majority of inhabitants were converted to Hanifism, while the Oghuz brought the beginnings of the Turkic Turkmen language that came to dominate the area. The Turkic period was a time of cultural fusion and growth, as Islamic traditions brought by the Arabs merged with local Iranian cultures, and the city of Merv became a centre of commerce, science, and innovation, being an influential capital of several Islamic caliphates. The cultural landscape of Turkmenistan was further altered by Turkic invaders and rulers such as the Seljuks. Genghis Khan and Mongol invasions devastated the region during the late Middle Ages, but their hold upon the area was transitional as Timur Leng and Uzbeks later contested the land.

Modern Turkmenistan was radically transformed by the invasion of the Russian Empire, which conquered and annexed the region in the late 19th century. Later, the Russian Revolution of 1917 would ultimately transform Turkmenistan from an Islamic and nomadic tribal society to an industrialized and urbanist Leninist socialist republic during the Soviet era. Independence came in 1991, as Saparmyrat Nyýazow, a former member of the local branch of the CPSU, declared himself the absolute president for life, taking up the title "Türkmenbaşy," also known as the Leader of the Turkmen, and transformed the newly independent Turkmenistan into a totalitarian conservative dictatorship under his absolute rule. Turkmenistan has thus far been unable to significantly democratize itself, unlike most of the other former Soviet Republics, and Nyýazow ruled the country until his death on December 21, 2006. He was succeeded by Gurbanguly Berdimuhamedow in an election devoid of meaningful political competition and opposition, and Berdymuhamedow reversed many policies by Niyazov that were considered eccentric, including Nyýazow's pervasive cult of personality and the country's near total international and socioeconomic isolation, passing several economic reforms and making limited moves towards a multi-party system, although each party represented in the legislative body was under the regime's direct oversight, and open dissent against the government still faced widespread repression. Gurbanguly Berdimuhamedow was later succeeded by his son Serdar Berdimuhamedow after he stepped down from political office in March 2022, establishing a de facto political dynasty.

Ancient history

Scant remains point to early human settlements east of the Caspian Sea, possibly including Neanderthals, although the archaeology of the region as a whole is under researched. Bronze Age and Iron Age finds support the probability of advanced civilizations in the area including finds associated with a society known to the scholars as the Bactria-Margiana Archaeological Complex (BMAC) – near the modern cities of Mary (previously Merv), Djeitun and Gonur Depe.

By 2000 BCE, Indo-European peoples had settled throughout the region. Most of the present-day Turkmenistan was occupied by BMAC-related societies and the Dahae (also known as the Daae, Dahā, Daoi and similar names) – a tribal confederation located immediately east of the Caspian. The Massagetae and Scythians were also present, immediately north of BMAC and the Dahae.

Alexander the Great conquered the territory in the 4th century BC on his way to South Asia. In 330 BC, Alexander marched northward into Central Asia and founded the city of Alexandria near the Murghab River. Located on an important trade route, Alexandria later became the city of Merv. The ruins of Alexander's ancient city are still to be found and have been extensively researched. After Alexander's death his empire quickly fell apart. It was ruled by Seleucids before the satrap of Parthia declared independence. The Parthians – fierce, nomadic warriors from the north of Iran – then established the kingdom of Parthia, which covered present-day Turkmenistan and Iran. The Parthian kings ruled their domain from the city of Nisa – an area now located near the modern-day capital of Ashgabat – founded by Arsaces I (reigned c. 250–211 BC), and was reputedly the royal necropolis of the Parthian kings, although it has neither been established that the fortress at Nisa was a royal residence nor a mausoleum.

Excavations at Nisa have revealed substantial buildings, mausoleums and shrines, many inscribed documents, and a looted treasury. Many Hellenistic art works have been uncovered, as well as a large number of ivory rhytons, the outer rims decorated with Iranian subjects or classical mythological scenes.

During the 4th to early 7th century CE, much of the population was already in settlements around the fertile river valleys along the Amu Darya, and Merv and Nisa became centers of sericulture (the raising of silkworms). A busy caravan route, connecting Tang dynasty China and the city of Baghdad (in modern Iraq), passed through Merv. Thus, the city of Merv constituted an important prize for any conqueror.

Arab conquests and Islamization Central Asia came under Arab control after a series of invasions in the late 7th and early 8th centuries and was incorporated into Islamic Caliphate divided between provinces of Mawara'un Nahr and Khorasan. The Arab conquest brought the religion of Islam to all of the peoples of central Asia. The city of Merv was occupied by the lieutenants of the caliph Uthman ibn Affan, and was constituted as the capital of Khorasan. Using this city as their base, the Arabs, led by their commander Qutayba ibn Muslim, brought under subjection Balkh, Bukhara, Fergana and Kashgaria, and penetrated into China as far as the province of Gansu early in the 8th century.

Merv achieved some political spotlight in February 748 when Abu Muslim (d. 750) declared a new Abbasid dynasty at Merv, and set out from the city to conquer Iran and Iraq and establish a new capital at Baghdad. Abu Muslim was famously challenged by the goldsmith of Merv to do the right thing and not make war on fellow Muslims. The goldsmith was put to death.

In the latter part of the 8th century Merv became obnoxious to Islam as the centre of heretical propaganda preached by al-Muqanna "The Veiled Prophet of Khorasan". Present Turkmenistan was ruled by Tahirids between 821 and 873. In 873, Arab rule in Central Asia came to an end as a result of the Saffarid conquest. During their dominion Merv, like Samarkand and Bokhara, was one of the great schools of learning, and the celebrated historian Yaqut studied in its libraries. Merv produced a number of scholars in various branches of knowledge, such as Islamic law, Hadith, history, literature, and the like. Several scholars have the name: Marwazi (المروزي) designating them as hailing from Merv. But Saffarid rule was brief and they were defeated by Samanid in 901. The Samanid dynasty weakened after the second half of the 10th century and Ghaznavids took present Turkmenistan in the 990s. But, they challenged with Seljuks, newcomers from north. Seljuks' decisive victory against them, present Turkmenistan was passed to them in 1041.

Oghuz tribes The origins of the Turkmen may be traced back to the Oghuz confederation of nomadic pastoral tribes of the early Middle Ages, who lived in present-day Mongolia and around Lake Baikal in present-day southern Siberia. This confederation was composed of Turkic-speaking peoples who formed the basis of powerful steppe empires in Inner Asia. In the second half of the 8th century, Oghuz components migrated through Jungaria into Central Asia, and Arabic sources located them under the term Guzz in the area of the middle and lower Syrdariya in the 8th century. By the 10th century, the Oghuz had expanded west and north of the Aral Sea and into the steppe of present-day Kazakhstan, absorbing not only Iranians but also Turks from the Kipchak and Karluk ethnolinguistic groups. In the 11th century, the Muslim Turk scholar Mahmud al-Kashgari described the language of the Oghuz and Turkmen as distinct from that of other Turks and identified twenty-two Oghuz clans or sub-tribes, some of which appear in later Turkmen genealogies and legends as the core of the early Turkmen.

In Old Turkic inscriptions, there are references to several Oghuz groups like simply Oghuz, Üç-Oghuz ("three-Oghuz"; possibly Karluks),Gumilyov, L.N. "Ancient Turks". ch. 5 (in Russian) Altı-Oghuz ("six-Oghuz"), Sekiz-Oghuz ("eight-Oghuz"), possibly *Otuz Oghuz ("Thirty Oghuz"), and the Tiele-affiliated Toquz Oghuz ("nine-Oghuz") (Chinese: 九姓 Jiu Xing "Nine Surnames")Golden, Peter B. (2015) The Turkic Word in Mahmud al-Kashgari , p. 507-511Golden, Peter B. (1972) "The Migrations of the Oğuz" in Archivum Ottomanicum 4, p. 48 in different areas in the vicinity of the Altai Mountains. Despite, the similarity of names, the Toquz Oghuz confederation, from whom emerged the founders of the Uyghur Khaganate, was distinct from the Transoxianan Oghuz Turks who'd later found the Oghuz Yabgu State: for instances, Istakhri and Muhammad ibn Muhmad al-Tusi kept the Toquz Oghuz and Oghuz distinct and Ibn al-Faqih mentioned "the infidel Turk-Oghuz, the Toquz-Oghuz, and the Qarluq"Golden, Peter B. (1992). An Introduction to the History of the Turkic People. Otto Harrassowitz, Wiesbaden. p. 197-198 Even so, Golden notes the confusion in Latter Göktürks' and Uyghurs' inscriptions, where Oghuz apparently referred to Toquz Oghuz or another tribal grouping, who were also named Oghuz without a prefixed numeral; this confusion is also reflected in Sharaf al-Zaman al-Marwazi, who listed 12 Oghuz tribes, who were ruled by a "Toquz Khaqan" and some of whom were Toquz-Oghuz, on the border of Transoxiana and Khwarazm. At most, the Oghuz were possibly led by a core group of Toquz Oghuz clans or tribes.Golden (1992) p. 206-207 Likewise, Karluks and Oghuz Turks were distinct even though both were known as Turkmens in the 11th century;Divanü Lûgat-it-Türk, translation Besim Atalay, Turkish Language Association, , book: 1, page: 473. quote: "Karluks is a division of nomadic Turks. They are separate from Oghuz, but they are Turkmens like Oghuz."Kafesoğlu, İbrahim. (1958) "Türkmen Adı, Manası ve Mahiyeti," in Jean Deny Armağanı: Mélanges Jean Deny, eds., János Eckmann, Agâh Sırrı Levend and Mecdut Mansuroğlu (Ankara: Türk Tarih Kurumu Basımevi) p. 131 yet much later, Ilkhanate politician Rashid al-Din Hamadani in his Jami' al-tawarikh mentions Karluks as of the Oghuz (Turkmen) tribes.