Nanki-Poo, the son of the royal mikado, arrives in Titipu disguised as a peasant and looking for Yum-Yum. Without telling the truth about who he is, Nanki-Poo explains that several months earlier he had fallen in love with Yum-Yum; however she was already betrothed to Ko-Ko, a cheap tailor, and he saw that his suit was hopeless. However, he has since learned that Ko-Ko has been condemned to death for flirting; and he has come to find Yum-Yum, his true love.
Nanki-Poo’s high hopes are dashed once more when Pish-Tush, a noble lord, informs him that Ko-Ko was reprieved and raised to the rank of lord high executioner. Pooh-Bah, first lord of the treasury, lord chief justice, commander-in-chief, etc., enters next, and he also holds out no hope for Nanki-Poo. Then Ko-Ko himself enters, ready to execute “plenty of people whose loss will be a distinct gain to society at large.”
Next enters Yum-Yum, who reluctantly allows Ko-Ko to kiss her, even though she doesn’t love him; however, she catches sight of Nanki-Poo and rushes over to him. Nanki-Poo, expecting an angry reaction from Ko-Ko, blurts out that he loves Yum-Yum. “Anger!” responds Ko-Ko. “Not a bit, my boy. Why, I love her myself.”
The crowd departs, and Yum-Yum and Nanki-Poo are left alone. He confides to her that he is really the son of the mikado, but, ordered by his father to marry Katisha, an elderly lady of the court, he has fled. However, they realize the hopelessness of their situation–and, sadly, they part.
Ko-Ko, Pooh-Bah, and Pish-Tush enter, bearing a letter from the mikado which complains that no executions have taken place in Titipu for a year and, unless somebody is beheaded within the month, Titipu will be reduced to a mere village.
Nanki-Poo decides that his only option is to commit suicide, but Ko-Ko persuades Nanki Poo to let him behead him instead. To clinch the deal, Ko-Ko even agrees to let Nanki-Poo marry Yum-Yum, providing he agrees to be executed in one month.
As wedding preparations progress, Ko-Ko arrives with bad news: he has learned that the law dictates that when a man is beheaded, his wife must be buried alive. Yum-Yum, while not wishing to appear selfish, points out that this revelation does change things. In despair, Nanki-Poo pulls out a dagger and threatens to kill himself if Ko-Ko doesn’t agree to behead him now. However, Ko-Ko can’t; he can’t kill anything, not even a fly. Then, just before the mikado arrives, they come up with a solution: Nanki-Poo and Yum-Yum will be married and will go into hiding, while everyone pretends that the execution has taken place.
When the mikado and Katisha arrive, he is pleased that an execution has taken place, but admits that his real purpose in visiting is to find his son. Katisha spots the name on the execution certificate–Nanki-Poo!–and the mikado, while agreeing that a mistake has certainly been made, says that killing the royal heir involves a horrible death.
Nanki-Poo surreptitiously suggests that Ko-Ko marry Katisha; that way Nanki-Poo can come back to life, no one will be killed, and Katisha will be off his back. Ko-Ko, while unenthusiastic, agrees. All are happy, except the mikado, who says that now no one has been executed. Ko-Ko comes up with the explanation: “When your majesty says, ‘let a thing be done,’ it’s as good as done–practically is done–because your majesty’s word is law.” The mikado is satisfied, and everyone happily sings the finale.