An imaginary Egypt.
Three Ladies attendant on the Queen of the Night save the fainting Prince Tamino from a serpent. When they leave to tell the Queen, the birdcatcher Papageno bounces in and boasts to Tamino that it was he who slew the serpent. The Ladies return to give Tamino a portrait of the Queen's daughter, Pamina, who they say is enslaved by the evil Sarastro, and they padlock Papageno's mouth for lying. The Queen, appearing in a burst of thunder, laments the loss of her daughter; she charges Tamino with Pamina's rescue. The Ladies hand a magic flute to Tamino and magic silver bells to Papageno to ensure their safety, appointing Three Genii to guide them.
Sarastro's Moorish slave Monostatos pursues Pamina but is frightened away by the feather-covered Papageno, who tells Pamina that Tamino loves her and intends to save her.
Led to the Temple of Sarastro, Tamino is advised by a High Priest that it is the Queen, not Sarastro, who is evil. Hearing that Pamina is safe, Tamino charms the animals with his flute, then rushes to follow the sound of Papageno's pipes.
Monostatos and his retainers chase Papageno and Pamina but are rendered helpless by Papageno's magic bells. Sarastro, entering in ceremony, promises Pamina eventual freedom and punishes Monostatos. Pamina is enchanted by a glimpse of Tamino, who is led into the temple with Papageno.
Sarastro tells his priests that Tamino will undergo initiation rites. Sworn to silence, Tamino is impervious to the temptations of the Queen's Ladies, who have no trouble derailing the cheerful Papageno from his course of virtue.
The Queen of the Night dismisses Monostatos, whom she finds kissing the sleeping Pamina, and gives her daughter a dagger with which to murder Sarastro. The weeping Pamina is confronted and consoled by Sarastro.
The gourmand Papageno is just as quick to break a new oath of fasting, and he jokes with a flirtatious old lady, who vanishes when asked her name. Tamino remains steadfast, breaking Pamina's heart: she cannot understand his silence.
The priests inform Tamino that he has only two more trials to complete his initiation. Papageno is eliminated but settles for the old lady, who turns into a young Papagena when the resigned Papageno promises to be faithful. She disappears, however.
After the Genii save the despairing Pamina from suicide, she finds Tamino and walks with him through the ordeals by water and fire, protected by the magic flute.
Papageno also is saved from attempted suicide by the Genii, who remind him to use his magic bells, which summon Papagena. The two plan for the future and move into a bird's nest.
The Queen of the Night, her Three Ladies and Monostatos attack the temple but are defeated and banished. Sarastro joins Pamina and Tamino as the throng hails Isis and Osiris, the triumph of courage, virtue and wisdom.