Pursued by a serpent which he is unable to kill because he has run out of arrows, Prince Tamino faints. Three veiled ladies kill the serpent and fall in love with the handsome stranger, each wishing to stay with him while the others tell their queen what has happened. Eventually they leave. A feather-clad, pipe-playing figure arrives: Papageno the bird catcher, who boasts to have killed the serpent. The three ladies return and padlock Papageno's mouth to stop him telling more lies. They give Tamino a portrait of Pamina, the daughter of the Queen of the Night. He falls in love with it.
The ladies tell him that Pamina has been enslaved by an evil demon called Sarastro. Tamino swears to save her.
A clap of thunder heralds the arrival of the queen, who promises that her daughter shall be Tamino's bride if he rescues her. The ladies remove Papageno's padlock and give Tamino a magic flute to help him in his quest.
Ordering Papageno to go with him, they give him a set of bells to use in time of need, explaining that three spirits will guide Tamino to Sarastro's domain.
Pamina tries to escape from the advances of the moor Monostatos, who is supposed to be guarding her. She faints as Papageno appears. He and Monostatos take each other for the devil. Monostatos flees. Papageno tells Pamina about the handsome prince who has fallen in love with her and is coming to rescue her. She consoles Papageno who longs for a wife and assures him that a loving heart will surely find a partner.
The three spirits leave Tamino in front of Sarastro's temple. He is turned back by unseen voices as he tries to enter the first two doors. A priestly figure bars his way to the third. From this man, the Speaker, Tamino learns that although Pamina is in Sarastro's realm, things are not as the Queen of the Night has represented them. But Tamino is not yet fit to understand the mysteries of the realm where Sarastro rules in wisdom. The Speaker disappears, but the voices tell Tamino that Pamina is alive. He expresses his joy by playing the flute. He hears Papageno's pipes and sets off to find him. Meanwhile Papageno and Pamina have been following the sound of the flute. They are overtaken by Monostatos and his slaves who are about to drag them off in chains when Papageno remembers his magic bells. Monostatos and the slaves dance off, forgetting their intention.
Sarastro and priests of the brotherhood arrive. Pamina tells him that she has tried to escape because of Monostatos. Sarastro is kind, but tells her that she cannot yet be set free because of her mother's evil influence.
Monostatos has captured Tamino. Pamina and Tamino rush into each other's arms. Sarastro orders that Monostatos be whipped and Tamino and Papageno be led into the temple to be purified.
Sarastro urges the brotherhood to allow Tamino to undergo the trials that will make him worthy to join their band, explaining that the gods have ordained Pamina as Tamino's wife. He claims that it is for this reason that he took her from her mother.
Two priests ask Tamino and Papageno if they are prepared to undergo the trials. Tamino is ready. Papageno demurs, but weakens when told that the gods have a wife in store for him, just like himself and called Papagena.
The priests impose silence on them, warn them against the wiles of women and leave them in the dark. The three ladies appear and threaten vengeance, but Tamino ignores them, advising Papageno to do the same. The ladies are driven off by the brotherhood. The priests commend Tamino for his steadfastness and lead him and the reluctant Papageno off to the next trial.
Monostatos tries to kiss the sleeping Pamina, but is frightened off by the arrival of the Queen of the Night, who gives Pamina a dagger, ordering her to kill Sarastro and bring back to her the circle of the sun which had been given to Sarastro by her late husband. Pamina expresses her revulsion at the thought of killing. Monostatos, who has been eavesdropping, tries to blackmail her: he will not warn Sarastro of the murder plot if Pamina agrees to love him. But Sarastro himself appears, sends Monostatos away and assures Pamina that her mother is safe from him, since no thoughts of vengeance are permitted in his realm.
Tamino and Papageno are led in by the priests and left alone. Papageno complains of thirst. An old woman gives him water, tells him he is her sweetheart and disappears. The spirits bring back Tamino's flute and Papageno's bells, which had been taken from them. They also bring a feast which Papageno attacks with gusto, while Tamino abstains, playing the flute instead.
The sound draws Pamina, who is distressed when Tamino refuses to speak to her. Even Papageno, his mouth full of food, does not answer. She longs for death.
The priests rejoice at Tamino's progress. Sarastro tells Tamino and Pamina to bid each other farewell for ever. Papageno is rejected by the brotherhood, but replies that there are more of his kind than theirs in the world. All he wants is a wife. The old woman appears. When Papageno reluctantly promises to be faithful to her, she changes into a young and beautiful girl, Papagena. But she is taken away by the priests.
The three spirits stop Pamina from killing herself, assuring her that Tamino would be heartbroken. They offer to take her to him.
Two men in armor give Tamino advice and tell him that he may now speak to Pamina. She appears, and together the couple undergo the ordeals of fire and water, protected by the magic flute as they go.
The three spirits prevent Papageno from committing suicide in his despair at the loss of Papagena. Following their advice, he plays his magic bells, and she appears. They joyfully make future plans for having many children.
The Queen of the Night, her ladies and Monostatos, who has joined them in the hope of getting Pamina, attack the temple but are repulsed and defeated.
Sarastro leads the brotherhood in celebration of the triumph of light, beauty and wisdom. Tamino and Pamina are united.