He was powerful ruler who, learning that his sister-in-law had been unfaithful to his brother, decides that all women are destined to be unfaithful. He has his wife killed, and proceeds to marry a virgin, only to have her killed the next morning. He continue this practice, marrying virgins each day and having them executed the next morning. The person whose job it is to find virgins for the ruler eventually runs out of virgins except for his own daughter. He reluctantly offers his daughter to the ruler, who marries her.
That night, the young bride tells her new husband a story, but she does not tell him how the story ends. His curiosity forces him to keep her alive the next day, because she promises to finish the story. The second night, she finished the story but starts a new one, also refusing to tell him the ending. A pattern starts, of consecutive nights of story-telling that must be completed the next day, and last for 1001 nights. The daughter's name, according to the legend, was Scheherazade.
This legend and the stories told were collected during Islam's Golden Age, and are called 1001 Nights; an English language edition in the early 1700s called it simply Arabian Nights. From this collection we get the tales of Aladdin and the magic lamp, of Ali Baba and the 40 thieves, and of Sinbad the Sailor—except that they were not part of the original: they were added by the creator of the first French translation, who got them from a Syrian writer visiting Paris.
The collection is first mentioned in a 9th century fragment, and then in 947CE in a discussion of legends from Arabic, Greek, and Iranian tales. In 987, Ibn al-Nadīm (the biographer who talks about Jabir ibn Hayyan, and who connects him with the ruler at the center of the 1001 Nights) says the author who began collecting the tales died when only 480 were complete.
Characters include the historical Barmaki (see the above link) and Harun al-Rashid, jinn, sorcerers, and ghouls. Story elements include comedy, romance, tragedies, burlesques and erotica, and historical tales. The tales mentioned above that were added have drawn attention away from the fantastical ideas found in the originals:
- a quest for immortality that lads to the Garden of Eden
- travel across the cosmos
- an underwater society that is the opposite of society on land
- a flying mechanical horse that can go to outer space
- an expedition across the Sahara to find a brass container used by Solomon to trap a jinn
- mermaids, talking serpents, talking trees, jinns