The Ramakien (sometimes spelled Ramakian) is the Thai version of the ancient Indian epic, the Ramayana. That tale, to summarize most briefly, tells of Rama, an incarnation of Vishnu who becomes king of Ayodhaya, and his beautiful and virtuous wife Sita. The long story begins with court intrigue which leads to Rama renouncing the throne and going into exile. Then Sita is abducted by Ravana; Rama, with the help of the monkey general Hanuman, recovers her, but believing she has been unfaithful, he repudiates her, and she kills herself, after which he realizes his error. (Jerk.) A meaningful epic on many levels - moral, spiritual, mythological, social, and even historical - one purpose of the Ramayana was to bolster the power of the earthly kings and seal their divinity by linking them with the talismanic exploits of the great king Rama.
Given this, it is unsurprising that the Ramayana found its way early into Southeast Asia, to be seized upon and used by monarchs trying to retain their insecure kingly tenure or by usurpers attempting to create a genealogy which would justify their position. It is featured in the magnificent bas-reliefs of Angkor Wat and is the root of the name of an early Siamese king, Ramkhamhaeng, who ruled the thirteenth century polity of Sukhothai. The succeeding great Thai polity had as its capital Ayuthaya, obviously named after Rama's capital, and though that city undoubtedly had Thai versions of the Ramakien, they were lost when the Burmese sacked the kingdom in 1767. Taksin wrote a version of the Ramakien when he established the next capital in Thonburi, as did Rama I, who after Taksin set up shop across the Chao Phraya river in Bangkok. It is this latter version which is taken as the classic one in Thailand today, though the story was substantially embroidered by Rama II, the next king. The story is performed in plays and in shadow theatre, and is featured visually in many wat (temples) around the country, including gorgeous bas-reliefs at Wat Pho and beautiful murals on the walls of Wat Phra Kaew.
Rama III began the custom of calling the kings of the currently ruling Chakri line Rama. Part of the reason for this was that Rama is easier for farang (westerners) to pronounce than the kings' long and convoluted Thai names, but he was also motivated to further solidify the dynasty's claim to the throne by making the link with the mythical Rama more explicit.
While the Ramakien closely follows the Ramayana, it has many quintessentially Thai touches that make it very much a tale from that lovely kingdom. Ram and Sida are easily recognizable, and not just in name, but in the Thai version Ram is a reincarnation of the Buddha, thus transmuting a Hindu mythos into a Buddhist one. Ravana is renamed Tosakan, and though he is still a demon up to dastardly tricks, he is not wholly evil; in the Thai version he is genuinely in love with Sida, and it is the strength of his emotions which lead him to do bad things, lending him a pitiable air which is very much in keeping with Thai sympathetic tendencies. Hanuman figures in the story as well, but unlike his chaste Hindu counterpart, this simian soldier is a trickster and a great lover whose amorous exploits enliven the story. And in a Thai innovative twist, Ram's lack of trust in the pregnant Sida's fidelity becomes so great that he condemns her to death at the hands of his brother Lak. However, the sword that is to sever her head turns into flowers and falls around her neck as a garland, and so Sita is saved; she goes into exile and bears a son. Many years pass, and finally the gods, who have followed the estrangement with interest and some impatience, intervene; after they hear both sides of the story, they chastise Ram for his mistrust and Sida for her obstinancy, and the two are reconciled. A happy ending, with male jealousy and female intractability overcome by divine intervention. Perfect, and perfectly Thai.
I used John Cadet's beautiful coffee table book Ramakien as background to this node; besides an English version of the story, the book features stone rubbings from the bas-reliefs at Wat Pho.
www.inm-asiaguides.com/thailand/erama.htm features some of the paintings from Wat Phra Kaew as well as the bare bones of the story.
www.seasite.niu.edu/Thai/literature/ramakian/text.htm has a longer summary of the story and some good contextual information.