The Turkmens of Turkmenistan should not be confused with the Turkmens of Iraq and Syria. Although they all speak closely-related languages, the Iraqi and Syrian Turkmens are descended from Oghuz Turks who colonized the Fertile Crescent during The High Middle Ages and have much more in common with the Turkish and Azerbaijani peoples genetically, culturally, and linguistically.
Most of Turkmenistan's area is taken up by the massive Karakum cold desert, so population is concentrated in the two large oases to the north and south, which were known in ancient times as Khwarezm and Margiana, respectively. These two developed some of the most advanced cultures in Central Asia, but thing is, while Turkic peoples dominate the modern life of the area, ancient Khwarezm and Margiana were unquestionably part of the Iranian civilization. In fact, the Zoroastrian scripture Avesta lists the latter as one of the lands specifically created by Ahura Mazda for the Iranian peoples.
The Dahae nomadic confederation was one of the first peoples to live in the area. They were brought under control of the Persian Achaemenids, but broke away when the empire was annexed by Alexander. They notably did not succumb to the Greeks' invasion, although a part of Margiana (specifically the city of Merv, now known as Mary) did fall and was known as "Alexandria Margiana" for some time. Then the land was conquered by the Parthians and Sassanians. Arabs next came; their conquest was fully complete when Khwarezm fell to Qutayba ibn Muslim of the Umayyads. In the eastern coast of the Caspian Sea, the Turks arrived from the former Western Turkic Khaganate and formed the Oghuz Yabgu State. This state is important as being the origin of modern-day Turkmens, who generally claim them as their foremost ancestors. It was also from the Oghuz Yabgu that the Turks moved through the Iranian Plateau, the Middle East, and eventually the Anatolian Peninsula.
After a series of foreign rule by Persians, the region came into spotlight when the Turks set up three major empires: the Ghaznavids, the Seljuks, and the Khwarezmians. Turkification of the region began in the earnest around this time. Gurganj (present-day Konye-Urgench) was the capital of the Khwarezmians for over a century, up until the Mongol invasions. During this time, the Khwarezmians was a center of the Islamic Golden Age and one of the greatest powers in the world; Merv was claimed to be the world's most populous city in the 12th century. It produced many thinkers and scholars, including polymath and geographer Muhammad ibn Ahmad Al Biruni and Muhammad ibn Musa al-Khwarizmi, who made timeless contribution to mathematics and astronomy. The Europeans latinized his last name as Algaurizin, and then Algoritmi, and finally Algorithm. And now you know.
The fairytale didn't last forever, however. In the 13th century, Genghis Khan and his sons marched west into the Iranian Plateau along with their army and requested the surrender of the empires there. They refused and what followed was, to describe the least, catastrophe. Bactria and Sogdia were sacked and looted, Persia was reduced to lowly vassal, but their sufferings couldn't compare to what happened to the Khwarezmians. Genghis Khan was extremely furious against anyone who betrayed him when they had his trust, and when the Khwarezmians massacred a convoy of Mongols sent to bring the peace treaty, the Mongols responded by completely razing the empire to the ground and destroying everything marking that a civilization used to exist there. Historians unanimously regarded the destruction of the Khwarezmians as one of the bloodiest conflicts in human history.
The Ilkhanate inherited Margiana and Khwarezm following the breakup of the Mongol Empire and under their rule the territory recovered, but never again to achieve the glory of the past. Turkification had solidified by this time. In the early modern era, the Khanate of Khiva emerged from the heart of Khwarezm and controlled the eastern coast of the Caspian Sea. It was an Uzbek polity; the Turkmens were never interested in leaving their nomadic way of life. In the 19th century, the Russians annexed Central Asia and organized Margiana and the Karakum Desert as part of the Transcaspian Oblast, while Khwarezm was left at the hands of the Khiva protectorate. The Russian Revolution made them independent for a while, but a futile Basmachi movement didn't stop the Soviets to conquer and made the region communist. First assigned under the Turkestan Autonomous Soviet Socialist Republic, the Turkmen Soviet Socialist Republic was formed in 1925, with a half of the former Khorezm People's Soviet Republic tacked to the north. It declared independence in October 1991, which was recognized two months later as part of The Great Politics Mess-Up.
However, things got worse from there. The first post-Soviet president, Saparmyrat Nyýazow, installed a cult of personality rivaled only by North Korea or the Stalinist USSR. He renamed all months and days in the calendar (including one named after his mother), built a gigantic golden statue of himself in Ashgabat, tried to build an enormous indoor ice skating rink near the capital (so people living in this desert country could learn to skate), banned things like the opera, circuses, video games and even gold tooth fillings and news presenters using makeup (because he was "having trouble telling them apart"), gave himself the title "Türkmenbaşy" (Leader of the Turkmens), renamed Krasnovodsk to that title, shut down all hospitals outside Ashgabat, arguing that sick Turkmens could "come to the capital" for treatment, wrote the Ruhnama, a book which was required to be memorized perfectly to hold government positions, apply for higher education, or even to own a driver's license and passed off as a text mosques were required by law (on penalty of having the mosques shut down at best) to treat on the same level as the Quran - all despite Nyýazow being "somewhat illiterate", and eventually declared himself president-for-life.
Fortunately, that "for-life" part didn't last long. Nyýazow died of a heart attack on 21 December 2006, and was succeeded by Gurbanguly Mälikgulyýewiç Berdimuhamedow in an election two months later. Ironically, Berdimuhamedow previously served as a dentist whose pension was taken away by Nyýazow before he died; Berdimuhamedow returned the favor by restoring pensions to 100,000 affected doctors. To this day, Turkmenistan still qualifies as a People's Republic of Tyranny, being a single-party state (but just so you know how democratic they are, the one party is named the "Democratic Party of Turkmenistan"), while Berdimuhamedow has taken steps to dismantle Nyýazow's cult of personality in favor of his own.
The country's population is overwhelmingly (85%) made of ethnic Turkmens, who were and to some extent are still pastoral nomads. The Soviet rule forced them to go urban, but there has been revivals of their traditional way of life. Their language, originally written with the Arabic script (and still is in Iran and Afghanistan) and then Cyrillic, is now written with a strange Latin orthography (see Berdimuhamedow's name above) compared to other Latinate Turkic orthographies. It was originally even weirder; the dollar, yen, and cent symbols, were used, for example.
There are also some Uzbeks in the former Khwarezm, and some Russians lounging in the cities. Surprisingly, there are very few Persians/Tajiks, in spite of the country's close proximity to Iran and large numbers of them in neighboring Uzbekistan. Conversely, a centuries-old Turkmen community exists in Iran, numbering approximately 1.4 million and concentrated in a region of Golestan Province aptly known as the Turkmen Sahra ("Turkmen desert"). They are often lumped together with other nomadic Turks of Iran, particularly with the closely-related Khorasani Turks, but what separates the Turkmens with other Iranian Turks is that they are one of the two major ethnicities in Iran who still closely identify with Sunni Islam after the 16th century (long story short, there's an aggressive evangelization campaign in Iran during that period, not unlike the contemporaneous Reformation in Europe. It's the reason why Iran is currently majority Shia Muslim in a sea of Sunnism).
The Turkmen flag