Following a lengthy overture, ACT ONE opens outside the farmhouse of Švanda. Two foresters appear, chasing after the notorious robber Babinsky. Švanda's wife Dorotka tells them that her husband is away for the moment, and she hasn't seen anyone else around in days.
But when the foresters leave, Babinsky drops out of a nearby tree, dusting himself off. Dorotka wants to know who he is, but Babinsky won't say.
Švanda then returns, and we find out that he's almost as famous as Babinsky. Švanda is a well-known piper, and Babinsky tells him he should be travelling far and wide, making lots of money -- not slaving away on his farm.
When Dorotka goes into the house, to prepare a meal, the two men stay outside to talk. Babinsky tells Švanda about a nearby kingdom, ruled by a stern, coldhearted queen. She's been searching for something to make her happy, and Babinsky says Švanda, with his pipes, might just do the trick. Excited, Švanda agrees to give it a try.
When Dorotka comes back outside, Babinsky and Švanda are gone. Babinsky has left one of his distinctive cuffs behind, with a note saying it's a "bond for Švanda's safe return." Dorotka prays for help, and goes off to find him.
The next scene is in the palace of the icy queen, where everything is dark and gloomy. Dancers try to lighten the mood, and we hear the lively, orchestral Polka that's one of the opera's most famous numbers. It's no use. The queen is under the spell of an evil sorcerer.
But everything changes when Švanda arrives to play his pipes. Soon, the entire court is laughing and dancing, including the queen herself. She's so happy that she actually offers to marry Švanda. And, lost in the moment, he forgets all about his wife, and agrees -- planting an impetuous kiss on the joyful queen.
The moment doesn't last long. Dorotka soon appears, searching for her husband. When the queen discovers who Dorotka is, she's furious, and says Dorotka and Švanda must both be put to death.
In the following scene, their execution has been prepared. Švanda is granted a final request, and wants to play his pipes. But the pipes have disappeared. The executioner raises his axe, but somehow, it's been replaced by a harmless broom -- adorned with a distinctive cuff. Babinsky has arrived in the nick of time, along with Švanda's bagpipes.
Švanda begins to play. Soon everyone is happy again, and they all go off dancing, leaving Švanda and Dorotka alone with Babinsky. Dorotka demands to know if Švanda has been unfaithful. He says no, of course not. And, forgetting himself, he says, "I never even kissed her! And the devil take me if I'm lying."
And that's exactly what happens. Švanda is immediately taken away to the underworld. Dorotka is grief-stricken, blaming her own jealousy for everything. As the act ends, Babinsky tries to console her. In a famous duet, he says he'll travel to hell itself, and bring Švanda home.
ACT TWO begins in the underworld, where the Devil is hoping Švanda will entertain the local residents with his pipes. Švanda refuses. And because it was his own oath that delivered him to the underworld, he's free to make his own decisions. Those, it seems, are the official rules of hell.
So the Devil borrows the pipes from Švanda, and gives it a try himself. The result is an off-key parody of the famous Polka heard back in Act One. The Devil does manage to get a few ghosts and bats dancing, but that's about it. And the Devil wants more. So he conjures up a vision of Dorotka, and uses it to trick Švanda into signing away his soul. With that done, Švanda has no choice but to plays his pipes whenever the Devil commands.
But all is not lost, as Babinsky soon arrives. He's committed so many evil deeds that the residents of hell know him all too well. Babinsky sits down to a game of cards with the Devil. And he wins -- when his cheating is even more effective than the devil's.
The Devil has wagered half his kingdom on the outcome, and Babinsky now owns the half of the underworld that holds all the food and wine -- even the crown jewels. That's more that the Devil can take, and the two make a deal. The devil will keep his kingdom, and Švanda can take back his soul. With the arrangement made, Švanda plays his pipes, while he and Babinsky head for home.
In the final scene, Švanda is back outside his farmhouse, eager to see Dorotka. But Babinsky says there's a problem. Time passes faster here than it does in hell, he declares. So much faster that Dorotka has aged 20 years. She's old now, he says, and wrinkled, and her hair is falling out!
Švanda says it doesn't matter, and calls to her anyway. And when Dorotka appears, she's as young and beautiful as ever. It seems Babinsky was lying. He's always had an eye for Dorotka, and thought he might just talk Švanda into leaving her. But, no such luck. Švanda and Dorotka are reunited, and the entire village celebrates as the opera ends.