Harun al-Rashid notices that Basra has not paid its annual tribute, and sends his friend Abu Ishaq al-Mawsill to investigate. The governor, Abdullah bin Fazil (or Abdallah ibn Fadil) hosts him for three days. One night, Abu Ishaq sees him take a whip, food and water into a room where there are two dogs. He whips them, and then soothes and feeds them. This happens the next night as well.
Abu Ishaq tells the caliph of this strange occurrence, so the caliph summons Abdullah and asks what's going on. Abdullah explains that the ogs are his brothers under an enchantment. After their father's death, Abdullah ran his father's shop, while the brothers took their inheritance of money and went travelling, but returned shipwrecked and destitute. Abdullah helped them out, and then they convinced him to go on a new journey with them. They made anchor at an island to find supplies, and Abdullah saw a dragon attacking a snake. He killed the dragon, and the snake revealed itself as a beautiful jinniyya.
The brothers continued their voyage but got lost, and stopped at a mountain for more supplies. Abdullah sees a city in the distance but is the only one brave enough to approach. He finds a magnificent city full of treasure, but all of the inhabitants have been turned to stone. In the palace, he meets a young woman reciting the Koran, and he falls in love. She explained that everyone else refused to convert to Islam and stop worshipping idols, so they were petrified, but she converted. A man in green, al-Khadir, gave her a pomegranate tree to eat from, visits her regularly, and predicted Abdullah's arrival. Abdullah takes her and some treasure back, but the brothers are not satisfied with sharing the treasure, and want the young woman. When Abdullah refuses, they throw him overboard. A large bird saves him and takes him to a djinn's palace, where the serpent-jinniyya lives. She takes him back to the ship and turns his brothers into dogs, and orders that they be whipped every night for twelve years.
With the story concluded, the caliph writes a decree that the dogs can't be whipped anymore and should be freed from their curse. Abdullah doesn't whip the dogs the next night, and the jinniyya appears. He shows her the letter and she asks her father for advice, and he says they must obey the caliph. The brothers are restored to humanity. However, the jinniyya tells Abdullah that the young woman from the city drowned.
The caliph makes Abdullah governor and his brothers share his stature, but are still jealous and decide to drug him and throw him into the river. A dolphin brings him to shore and he is rescued by a caravan that takes him to a holy woman - who is the very same woman he saved and was told had drowned. Al-Khadir, the man in green, saved her, and now he takes them both back to Basra. The two brothers are crucified for their treasury.
- Khidr or Al-Khadir is a popular saint and servant of God mentioned in the Quran.