Act I
Scene: Court of Hassan's House.
Wealthy Hassan is contented with his peaceful life in Persia. He is surrounded by his twenty-five wives, (he has carelessly miscounted and dismisses his 26th wife) including his first wife, Dancing Sunbeam, who wishes that they would mingle more with high society. Hassan is known for generously entertaining travellers and the poor in his home. Abdallah, the High Priest, arrives. Abdallah accuses Hassan of madness, because he consorts with beggars and other riff-raff, which he says does not follow Islam. He threatens to drive the evil spirit out of Hassan by force. As evidence of his sanity, Hassan offers to make out his will in Abdallah's favour. Abdallah agrees that anyone who would do this must be sane. Dancing Sunbeam plans to share Hassan's fortune with Abdallah should Hassan perish.
Yussuf, a traveling story-teller, arrives, shortly followed by four of the Sultana's slaves, who have slipped out of the palace disguised as dancing girls to explore the outside world. One of the girls, Heart's Desire, quickly falls in love with Yussuf. Another is actually Rose-in-Bloom, the Sultana. They know that they will surely be executed if the Sultan learns of their absence. Yussuf says that he will ensure that they return home safely. Hassan invites Yussuf, the girls, and a crowd of beggars and cripples into his home, offering them supper. Yussuf sings them a drinking song, and the "dancing girls" also perform for them. Abdallah enters with two police offers to arrest the unruly group. Hassan helps the beggars escape while Abdallah reads the warrant.
Abdallah orders the dancing girls arrested. Heart's Desire, who is wearing the Sultana's ring, steps forward and claims that she is the Sultana. By doing so, she hopes to provide Rose-in-Bloom (the real Sultana) with an alibi. Abdallah, thinking he has found the Sultana consorting with another man, is delighted, as he is sure the Sultan will order Hassan's execution. Abdallah expects that he will inherit Hassan's wealth under the will. Dancing Sunbeam realises that Abdallah has double-crossed her, and she will not share any of Hassan's estate after all.
After Abdallah leaves, Hassan distributes a narcotic drug called "bhang," which he says will relieve the distress of their impending execution. Rose-in-Bloom giddily tells Hassan that she is the real Sultana. Hassan, anticipating his execution, takes a triple dose of "bhang". Heart's Desire announces that the Sultan himself is about to arrive, along with his Grand Vizier, Physician-in-Chief and Royal Executioner, all disguised as dancing dervishes. The Sultan has decided to investigate for himself the rumours of Hassan's mad behaviour.
Intoxicated with "bhang," Hassan tells them that he doesn't care about the Sultan or his Executioner. The Physician realises that Hassan has overdosed on "bhang". He says the effect of the drug is that Hassan will gradually consider himself a person of more and more importance, until he suddenly falls unconscious for ten hours. Hassan starts behaving exactly as the Physician had described, claiming that he actually is the Sultan. As evidence of this, he tells them that he will introduce the Sultana. The actual Sultan is incensed that anyone would imitate his Sultana and says that the perpetrator will be punished. In the meantime, he decides to play a trick on Hassan and tells the Vizier to conduct Hassan to the palace and treat him as if he were the Sultan. They tell Hassan's wives that Hassan has been leading a double-life and is really the Sultan disguised. Hassan, believing that he is the Sultan, orders Rose-in-Bloom to lift her veil, so all may see that she is the Sultana, and threatens her with execution should she refuse. Fortunately, he collapses from the drug's effects before she does so. The Sultan orders him taken to the palace.
Act II
Scene: Audience Hall of the Sultan's Palace, the next morning.
Yussuf sneaks into the Sultan's palace and tells Heart's Desire that he intends to ask the Sultan for her hand and will explain how they had met. She notes that the truth is likely to get them all executed and suggests that he make up a story instead. The Sultan enters, telling the members of his Court that they are to treat Hassan as if he were the Sultan. The Sultan is amused by Hassan's behaviour, as no one has ever treated him so disrespectfully. It also might be convenient to have a fake Sultan available, as he wants to take a holiday.
Dancing Sunbeam arrives. She has heard that Hassan is now the Sultan, and therefore she announces that she is now the Sultana and looks forward to her new social rank. The Sultan plays along, and he summons the real Sultana, Rose-in-Bloom, so that he can let her in on the joke. Rose-in-Bloom, however hears that a new Sultana has been installed and fears that the Sultan has discovered her excursion outside the palace. She is relieved to find that he does not know about it, but she is afraid that he will find out. She coyly asks him what he would do if, hypothetically, she were to sneak out on a lark. He replies that if she ever did do such a thing, she would be executed.
Hassan is brought in, still unconscious. When he wakes up, he is confused to find that he is being treated like a king and appalled to find that he now has 671 wives. Yussef arrives to ask the Sultan for Heart's Desire's hand in marriage, but he becomes flustered. Abdallah arrives to accuse the Sultana of consorting with Hassan. When the Sultan hears this, he calls an end to the practical joke. He orders Hassan executed. He further decrees that he will divorce Rose-in-Bloom and will force her to marry Yussuf, a mere story-teller. Yussuf and Heart's Desire are both despondent, as they now cannot marry each other.
Dancing Sunbeam enters, still believing that she is the new Sultana. The slave girls put a veil on Dancing Sunbeam. When the Executioner enters to carry out the Sultan's order, he mistakes Dancing Sunbeam for the Sultana and causes Yussuf to be married to her. Both Dancing Sunbeam and Yussuf are unhappy at the result. Hassan, though, is happy to be rid of the overbearing Dancing Sunbeam, although he assumes he has only a few minutes to live. The Vizier announces that the Sultan has relented and will allow the Sultana to offer an explanation. The Sultan is delighted to find that the Executioner divorced and married the wrong woman.
Heart's Desire explains that it was she who wore the Sultana's Royal Ring at Hassan's residence. Rose-in-Bloom is exonerated, but the Sultan decrees that Heart's Desire must die (for impersonating the Sultana), Abdallah must die (for making a false accusation), and Hassan remains condemned (for falsely claiming to have entertained a visit from the Sultana). Rose-in-Bloom begs the Sultan to spare her slave, as Heart's Desire has been telling her an interesting story, and she would like to hear the end of it. Hassan quickly claims to be the source of the story, and so the Sultan says he may live until he finishes telling it – as long as it has a happy ending.
The Sultan gives them a few minutes to compose themselves. Abdallah offers to help tell the story, and Hassan agrees after Abdallah returns the will, which Hassan tears up. None of them can think of an acceptable story, but when the Sultan returns, Hassan hits on an idea. He sings a song about "a small street Arab", and when it is over, he tells the Sultan that it is the story of his own life. Since the Sultan has decreed that it must have a happy ending, it follows that his execution must be cancelled. The Sultan admits that he has been outwitted, but he orders Dancing Sunbeam restored to Hassan, allowing Yussuf to marry Heart's Desire, and all ends happily.