Neither ‘Asim ibn Safwan, the elderly king of Egypt, or his vizier Faris ibn Salih have any sons. They hear of King Solomon, who controls the djinn and all living creatures, and the vizier goes to him for advice. Solomon's instructions are to kill two certain snakes and feed the meat to their wives, who will then each bear a son. The king's son is named Sayf al'Muluk, and the vizier's son is Sa'id. The royal astronomers predict many hardships for both. Solomon had given their fathers some gifts, including a pair of tunics for the two young men. Sayf al'Muluk finds a portrait of a woman embroidered on one, labeled Badi'at al-Jamal, daughter of the jinn king Shahyal ibn Sharukh, son of ‘Ad the Great, ruler over the city of Babel and the garden of Iram. Sayf al-Muluk falls in love immediately with the girl in the image and pines for her; after no one knows where the garden of Iram is, he sets out to find it himself. His ship sinks and Sa'id appears lost. His other companions are chased by a giant and locked into cages; Sayf al-Muluk is given to the princess as a gift, and they are there for four years. They finally escape, but Sayf al-Muluk is the only survivor after the others are eaten by crocodiles. He washes up on a mountain, where some large apes take him to a castle and he meets the young man who rules over them. He continues his journey and finds a black palace, where the missing princess of India, Dawlat Khatun, sits on the throne. She happens to be Badi'at al-Jamal's foster sister, as well. To free her, Sayf al'Muluk must slay the jinni's soul, which is hidden inside a sparrow, inside a box, inside eight caskets, inside seven chests, inside an alabaster coffer at the bottom of the sea. He succeeds and takes her away, and they wind up at her father's palace, where Sayf al-Muluk is reunited with Sa'id.
Badi'at al-Jamal and her mother are called to meet them. Although skeptical at first, Badi'at sees Sayf and falls in love with him. The queen of the djinn is wary of human-djinn marriages, and while she is thinking, evil jinn kidnap Sayf al-Muluk. The queen saves him in the end, and he marries Badi'at al-Jamal, while Sa'id marries Dawlat Khatun.
- King Mohammed Bin Sabaik and the Merchant Hasan