Nanki-Poo, the son of the Mikado of Japan, has fled his father's court to escape Katisha, a rather unattractive lady who intends to marry him. Disguised as a minstrel, he falls in love with Yum-Yum in the town of Titipu. But his love seems hopeless. Yum-Yum is engaged to marry Ko-Ko, her guardian and the Lord High Executioner.
The Mikado is struck by the fact that no executions have taken place in Titipu for over a year and decrees that unless someone is beheaded within one month, the Lord High Executioner shall be abolished. Ko-Ko must find someone to execute or lose his position. He believes his problem solved when he stumbles upon Nanki-Poo about to perform "the happy dispatch". Nanki-Poo agrees that Ko-Ko may behead him at the end of the month on condition that Ko-Ko permits him to marry Yum-Yum until then.
As Nanki-Poo and Yum-Yum prepare for their wedding, Ko-Ko bursts in with the news that wives of decapitated gentlemen are buried alive. Yum-Yum naturally becomes reluctant to marry so Nanki-Poo tells Ko-Ko that he might just as well be executed that very day. As Ko-Ko recoils from the thought of actually killing someone, the arrival of the Mikado is announced. In desperation, Ko-Ko tells Nanki-Poo to take Yum-Yum and never come back. He then conspires with Pooh-Bah, who holds all the official positions in Titipu except Executioner, and with Pitti-Sing, Yum-Yum's sister, to swear that Nanki-Poo has been duly executed.
But the Mikado announces to Ko-Ko that he is in search of his son, just as Katisha reads Nanki-Poo's name on the "death certificate". Ko-Ko, Pitti-Sing, and Pooh-Bah cringe in horror when the Mikado coolly informs them that they have killed the Heir Apparent and the punishment for that is a slow and painful death.
Ko-Ko, Pooh-Bah, and Pitti Sing realize that their only hope is to resurrect Nanki-Poo. He, however, refuses to return for fear of Katisha's wrath. In order to appease Katisha, Ko-Ko feigns undying love for her and persuades her to marry him. Nanki-Poo and Yum-Yum then reappear to the joy of everyone except Katisha, who is momentarily perturbed until she realizes that she has "a very good bargain" in her new husband, Ko-Ko. General rejoicing prevails.