Ali al-Zaybaq is a sharper in Cairo, who hears of the generosity of the rogue Ahmad al-Danaf and receives a letter from him inviting him to Baghdad to receive a stipend. He travels there in a caravan, defeating a lion and a brigand on the way. In Baghdad, Dalila the Crafty and her daughter Zaynab steal his clothes. However, he steals them back in a plot involving forty carrier pigeons. He is impressed by Zaynab's cleverness and asks to marry her, but is told to propose to her uncle Zurayq. Zurayq is a super-sharper with a purse of 1,000 gold dinars in his shop, and has challenged all the rogues to steal it. Ali makes three attempts, disguised as a pregnant woman, a groom, an a snake charmer, but fails each time. He finally steals it, only for Zurayq to immediately steal it back. Ali then disguises himself as Zurayq's wife and steals both his purse and his son. Finally, Ali is allowed to marry Zaynab.
For her dowry, he is asked to get the magic robe of Qamar, the daughter of a Jewish sorcerer named ‘Adhra. When Ali follows the sorcerer to his invisible castle and tries to kill him, the sorcerer turns him into stone, a donkey, a bear, and a dog, selling him each time at the market, only for him to be brought back. Finally Qamar, whose dreams have told her to convert to Islam, frees him. Her father is killed when he refuses to convert, and Ali marries Zaynab and Qamar and gets his stipend.