The territory of present-day Turkmenistan has been inhabited since the Stone Age, with evidence of agricultural communities as early as 6000 BC and of planned irrigation works from 3500 BC . The first states were Margiana and Parthia, from about 1000 BC . In 7th–6th centuries BC , Margiana was part of Bactria, while Parthia was part of the Median state. In the 6th–4th centuries BC the region was ruled by the Achaemenids, who were conquered by Alexander the Great at the end of the 4th century. In his wake there emerged a Parthian Empire which lasted until AD 224, when Persians of the Sassanid dynasty seized the territory. In the 5th century much of Turkmenistan was conquered by Ephthalites, who in turn were conquered in the 6th century by the Tiu-chue nomads, of Turkic origin. The Arab caliphate conquered Turkmenistan in 716, and began to introduce Islam. In the 10th century part of Turkmenistan was under Samanid control.
Oghuz Turks began to migrate into Turkmenistan in the 9th century. In 1040 the Seljuk clan took control of the territory, and held sway until the 13th century, when Turkmenistan was part of the Khwarazm-Shah state. The entire region was conquered by Mongols in 1219–1221, and Turkmenistan was split between the Golden Horde and the Chagatai Khanate, as well as the Hulaguid Khanate of Persia.
In the 1380s Turkmenistan became part of the empire of Timur (Tamerlane). By the 16th century part of the territory was ruled by the Khiva Khanate, part by Bukhara, and part by Persia. The course of the Amu Dar'ya river changed, and the Kara Kum desert claimed a great deal of once arable land.
Russia began to make commercial contacts with the Turkmens as early as the 16th century; by the 18th century almost all trade between Europe and Central Asia passed through Turkmenistan. Local tribes were used diplomatically by the Persians, Russians, and British as part of the Great Game of the 18th and 19th centuries. Beginning in 1865, Russia undertook direct annexation, which because of heavy resistance by the Turkmen tribesmen was not complete until the 1885, making Turkmenistan the last portion of the Russian Empire to be conquered. The territory then was called the Transcaspian District.
Turkmen joined the uprising of 1916, when the Tsar attempted to draft Central Asians into work battalions, and remained in general rebellion throughout the period of the revolution and civil war. Muslim and nationalist opposition, whom the Russians
called basmachi, resisted the Bolsheviks until 1924, when the area was made part of the Trans-Caspian Republic. In 1925, the present-day territory became a Soviet Socialist Republic.
Throughout the Soviet period, Turkmenistan was the poorest and least assimilated of the republics. In 1985, longtime Communist Party boss M. Gapurov was fired by Mikhail Gorbachev, who picked Sapamurat Niyazov as new republic head. Niyazov has remained in power ever since. On October 27, 1990, Niyazov received 98.3% of the popular vote in an uncontested election to the new post of president of Turkmenistan. Turkmenistan declared independence on 27 October 1991. After independence, Niyazov won another uncontested presidential election in June 1992 with 99.95% of the vote. In a referendum in January 1994, he received the support of 99.99% of the vote for extending his term until 2002. An elaborate cult of personality has grown up around Niyazov, who now prefers the title "Turkmenbashi," or "chief of all Turkmen." Niyazov is president, supreme commander of the armed forces, first secretary of the Democratic Party of Turkmenistan, head of the quasi-legislative Khalk Maslakhaty (People's Council), and chairman of the Cabinet of Ministers and the National Security Council. Changes to the Constitution were introduced in late December 1999 during a joint meeting of the Mejlis (legislature), the Khalk Maslakhaty, and Niyazov's National Revival Movement, to include naming Niyazov president for life.
Turkmenistan's "neutral" foreign policy is enshrined in its constitution. Niyazov has declared that Turkmenistan's "open door" or "permanent neutrality" policy precludes joining political or military alliances and entails good relations with the East and the West, though priority will be placed on relations with Central Asian and other Islamic states. Turkmenistan joined the Non-Aligned Movement in 1995, and the United Nations General Assembly in 1995 recognized Turkmenistan's status as a neutral state. Turkmenistan has pursued close ties with both Iran and Turkey. In addition to growing trade ties with Iran, Turkmenistan is also interested in cultural ties with the approximately one million Turkmen residing in Iran. Turkey is the largest foreign investor in Turkmenistan and has far surpassed Russia in trade turnover with Turkmenistan. Turkmenistan supports some of Russia's policies in the region while endeavoring, where possible, to resist, contravene, or reduce Russian influence. Russian military and border troops assisted Turkmenistan until it built up its own forces, and Russia's presence has been used to counter Uzbek policies in the region. In 1993, Russia and Turkmenistan agreed that Russian border guards would work with Turkmen border guards under Turkmen command at borders with Iran and Afghanistan. In 1999, Turkmenistan canceled this agreement, and the last of Russia's 1,000 border troops in Turkmenistan left in late 1999.
The new country has abundant resources that could bring in ample export earnings, ranging from oil, gas, electricity, coal, aluminum, and cotton to wool, grapes, and carpets. Turkmenistan's main natural gas export pipeline runs through Russia, which has closely controlled the volume, price, and destination. Seeking alternatives, Turkmenistan in December 1997 opened a 125-mile gas pipeline to connect with the Iranian pipeline system. On 18 November 1999, Turkmenistan, Azerbaijan, Georgia, and Turkey signed a declaration on a trans-Caspian and trans-Caucasus gas pipeline territory that would deliver Turkmen gas to Turkey (expected to be completed in 2002 with an eventual capacity of sixteen billion meters per year), boosting chances for international financing for the pipeline. In December 2002, Turkmenistan, Afghanistan, and Pakistan signed an agreement to build a 1,500-km pipeline to carry gas from Turkmenistan's Dauletabad-Donmez field through Afghanistan to Pakistan.
In October 2001, Azerbaijan announced the planned trans-Caspian gas pipeline would not be realized. It had discovered its own huge gas reserves in Shahdeniz, and subsequently demanded a share of the exports to the amount of half of the trans-Caspian pipeline's capacity. Turkmenistan regarded such demands as contrary to its interests. In July 2002, an Azerbaijani tanker exploded in the Turkmen port of Turkmenbashi, killing six Azeri sailors. Some blamed the Turkmen government for the incident. Suspicions between the two governments ran deep in 2002, as mutual enmity between Azerbaijan's president Heydar Aliyev and Niyazov has made the gap between the ethnically close nations wide.
Following the 11 September 2001 terrorist attacks on the United States, Turkmenistan offered to aid the US-coalition in its military and humanitarian campaign in Afghanistan. Over one-third of all food aid reaching Afghanistan since 11 September transited Turkmenistan. The United States has stated that Turkmenistan can play a positive role in the rebuilding of Afghanistan.
On 25 November 2002, an assassination attempt was made on Niyazov. Following the attack on his motorcade, the Niyazov government began a wide investigation, and 61 people were arrested in connection with the assassination plot. Turkmenistan's National Assembly granted powers to the Supreme Court to administer "special punishment" to people found guilty of involvement in the plot. The resolution permits the Supreme Court to hand out life sentences to those convicted, with no possibility of amnesty, pardon, early release, or change of prison. Former foreign minister Boris Shikhmuradov was sentenced to life in prison for his involvement. As of January 2003, more than 30 people were given lengthy sentences by Turkmen courts, including at least three life sentences amid reports of torture and coerced confessions. The US State Department expressed concern with Turkmenistan's conduct of the investigations into the assassination plot, stating that while the United States recognized the government's right to apprehend those involved, the US government could not condone actions that violate international practice. The United States claimed the Turkmen government conducted summary trials of alleged suspects without due process of law, and cited credible reports of torture and abuse of suspects.
In January 2003, the Turkmen government announced parliamentary elections would be held on 6 April, nearly two years ahead of schedule (elections had been scheduled for December 2004). Also in January, Niyazov ordered the forced relocation of ethnic Uzbeks living along the Turkmen border with Uzbekistan. He stated he wanted "unworthy people" to be moved from the border area and replaced with ethnic Turkmen.