Tamino, a handsome prince lost in a distant land, is pursued by a serpent and asks the gods to save him. He faints, and three ladies, attendants of the Queen of the Night, appear and kill the serpent. They find the unconscious prince extremely attractive, and each of them tries to convince the other two to leave. After arguing, they reluctantly decide to leave together. Tamino wakes up, and is surprised to find himself still alive. Papageno enters dressed as a bird. He describes his life as a bird-catcher, complaining he has no wife or girlfriend. Tamino introduces himself to Papageno, thinking Papageno killed the serpent. Papageno happily takes the credit – claiming he strangled it with his bare hands. The three ladies suddenly reappear and instead of giving Papageno wine, cake and figs, they give him water, a stone and place a padlock over his mouth as a warning not to lie. They give Tamino a portrait of the Queen of the Night's daughter Pamina, with whom Tamino falls instantly in love. The ladies tell Tamino that Pamina has been captured by Sarastro, whom they describe as a powerful, evil demon. Tamino vows to rescue Pamina. The Queen of the Night appears and promises Tamino that Pamina will be his if he rescues her from Sarastro. The Queen leaves and the ladies remove the padlock from Papageno's mouth with a warning not to lie any more. They give Tamino a magic flute which has the power to change sorrow into joy. They tell Papageno to go with Tamino, and give him magic bells for protection. The ladies introduce three child-spirits, who will guide Tamino and Papageno to Sarastro's temple. Together Tamino and Papageno set forth.
Pamina is dragged in by Sarastro's slaves, apparently having tried to escape. Monostatos, a blackamoor and chief of the slaves, orders the slaves to chain her and leave him alone with her. Papageno, sent ahead by Tamino to help find Pamina, enters. Monostatos and Papageno are each terrified by the other's strange appearance and both flee. Papageno returns and announces to Pamina that her mother has sent Tamino to save her. Pamina rejoices to hear that Tamino is in love with her. She offers sympathy and hope to Papageno, who longs for a wife. Together they reflect on the joys and sacred duties of marital love.
The three child-spirits lead Tamino to Sarastro's temple, promising that if he remains patient, wise and steadfast, he will succeed in rescuing Pamina. Tamino approaches the left-hand entrance and is denied access by voices from within. The same happens when he goes to the entrance on the right. But from the entrance in the middle, an old priest appears and lets Tamino in. He tells Tamino that Sarastro is benevolent, not evil, and that he should not trust the Queen of the Night. He promises that Tamino's confusion will be lifted when Tamino approaches the temple in a spirit of friendship. Tamino plays his magic flute. Animals appear and dance, enraptured, to his music. Tamino hears Papageno's pipes sounding offstage, and hurries off to find him. Papageno and Pamina search for Tamino. They are recaptured by Monostatos and his slaves. Papageno plays his magic bells, and Monostatos and his slaves begin to dance, and exit the stage, still dancing, mesmerised by the beauty of the music. Papageno and Pamina hear the sound of Sarastro's retinue approaching. Papageno is frightened and asks Pamina what they should say. She answers that they must tell the truth. Sarastro enters, with a crowd of followers. Pamina falls at Sarastro's feet and confesses that she tried to escape because Monostatos had forced his attentions on her. Sarastro receives her kindly and assures her that he wishes only for her happiness. But he refuses to return her to her mother, whom he describes as a proud, headstrong woman, and a bad influence on those around her. Pamina, he says, must be guided by a man.
Monostatos brings in Tamino. The two lovers see one another for the first time and embrace, causing indignation among Sarastro's followers. Monostatos tells Sarastro that he caught Papageno and Pamina trying to escape, and demands a reward. Sarastro, however, punishes Monostatos for his lustful behaviour toward Pamina, and sends him away. He announces that Tamino must undergo trials of wisdom in order to become worthy as Pamina's husband. The priests declare that virtue and righteousness will sanctify life and make mortals like gods. The council of priests of Isis and Osiris, headed by Sarastro, enters to the sound of a solemn march. Sarastro tells the priests that Tamino is ready to undergo the ordeals that will lead to enlightenment. He invokes the gods Isis and Osiris, asking them to protect Tamino and Pamina.
Tamino and Papageno are led in by two priests for the first trial. The two priests advise Tamino and Papageno of the dangers ahead of them, warn them of women's wiles and swear them to silence. The three ladies appear and try to frighten Tamino and Papageno into speaking. Papageno cannot resist answering the ladies, but Tamino remains aloof, angrily instructing Papageno not to listen to the ladies' threats and to keep quiet. Seeing that Tamino will not speak to them, the ladies withdraw in confusion.
Pamina is asleep. Monostatos approaches and gazes upon her with rapture. He is about to kiss the sleeping Pamina, when the Queen of the Night appears. Monostatos hides. In response to the Queen's questioning, Pamina explains that Tamino is joining Sarastro's brotherhood and she is thinking of accompanying him too. The Queen is not pleased. She explains that her husband was the previous owner of the temple and on his deathbed, gave the ownership to Sarastro instead of her, rendering the Queen powerless. She gives Pamina a dagger, ordering her to kill Sarastro with it and threatening to disown her if she does not. She leaves. Monostatos returns and tries to force Pamina's love by threatening to reveal the Queen's plot, but Sarastro enters and drives him off. Pamina begs Sarastro to forgive her mother and he reassures her that revenge and cruelty have no place in his domain
Tamino and Papageno are led in by priests, who remind them that they must remain silent. Papageno complains of thirst. An old woman enters and offers Papageno a cup of water. He drinks and teasingly asks whether she has a boyfriend. She replies that she does and that his name is Papageno. She disappears as Papageno asks for her name, and the three child-spirits bring in food, the magic flute, and the bells, sent from Sarastro. Tamino begins to play the flute, which summons Pamina. She tries to speak with him, but Tamino, bound by his vow of silence, cannot answer her, and Pamina begins to believe that he no longer loves her. She leaves in despair.
The priests celebrate Tamino's successes so far, and pray that he will succeed and become worthy of their order. Pamina is brought in and Sarastro instructs Pamina and Tamino to bid each other farewell before the greater trials ahead.
The priests grant Papageno's request for a glass of wine and he expresses his desire for a wife. The elderly woman reappears and warns him that unless he immediately promises to marry her, he will be imprisoned forever. When Papageno promises to love her faithfully she is transformed into the young and pretty Papagena. Papageno rushes to embrace her, but the priests drive him back, telling him that he is not yet worthy of her.
The three child-spirits hail the dawn. They observe Pamina, who is contemplating suicide because she believes Tamino has abandoned her. The child-spirits restrain her and reassure her of Tamino's love.
Two men in armor lead in Tamino. They recite one of the formal creeds of Isis and Osiris, promising enlightenment to those who successfully overcome the fear of death. Tamino declares that he is ready to be tested. Pamina calls to him. The men in armour assure him that the trial by silence is over and he is free to speak with her. Pamina enters and declares her intention to undergo the remaining trials with him. She hands him the magic flute to help them through the trials. Protected by the music of the magic flute, they pass unscathed through chambers of fire and water. The priests hail their triumph and invite the couple to enter the temple.
Papageno despairs at having lost Papagena and decides to hang himself. The three child-spirits appear and stop him. They advise him to play his magic bells to summon Papagena. She appears and, united, the happy couple stutter in astonishment and make bird-like courting sounds at each other. They plan their future and dream of the many children they will have together.
The traitorous Monostatos appears with the Queen of the Night and her three ladies. They plot to destroy the temple and the Queen confirms that she has promised her daughter Pamina to Monostatos. But before the conspirators can enter the temple, they are magically cast out into eternal night.
Sarastro announces the sun's triumph over the night, and hails the dawn of a new era of wisdom and brotherhood.