Die Zauberflöte, The Magic Flute, is indeed a work incorporating a good deal of Masonic allusions and symbolism.
To recognize this, it is first necessary to know something about the ritual used in Vienna in Mozart’s time. In the Entered Apprentice Degree, the candidate was required to be tried by the four elements of classical science - earth, air, fire and water. This occurs early in the initiation and once he passes through the four ordeals, he is qualified to become a brother. This is borrowed from the Eleusinian mysteries, in which the ordeals were so extreme that they were frequently fatal. This is still practiced in many jurisdictions and lodges today. I saw it in Garibaldi Lodge in New York City, conferred in Italian.
The libretto of The Magic Flute was written by Emanuel Schikaneder, a singer, actor and impresario, who was a friend of Mozart and a fellow member of the lodges Zur Wohltätigkeit [Beneficience] and Zur Neugekronnte Hoffnung [New-crowned Hope]. He did not just write it and give it to Mozart to put to music. During the summer of 1791, Mozart moved temporarily into Schikaneder’s house and they collaborated on the work, so that while the music is all Mozart’s, the libretto may be seen as a joint work. The opera premiered on 30 Sept. 1791, with Schikaneder playing the role of Papageno, and Mozart conducting and playing the celeste.
Very brief synopsis: After the overture featuring the famous three chords, the hero, Tamino, rushes onto the stage pursued by a huge serpent. Three ladies come to his rescue and kill the serpent. They inform Tamino that Pamina, the beautiful young daughter of the Queen of the Night, is being held captive by a wicked magician, Sarastro, and that Tamino is to rescue her. They give him a magic golden flute to ward off danger. The Queen of the Night appears and pours out her fanatic hatred of Sarastro. Tamino meets the birdcatcher Papageno, and together they set out for Sarasto’s castle. Papageno finds Pamina, frees her and they set out to find Tamino. Scene 3 is a grove with a temple labelled “Temple of Wisdom” and a colonnade of arches leading to two others, the Temple of Reason and the Temple of Nature. Tamino tries to enter the last two, but is warned off. When he tries the Temple of Wisdom, he is met by The Speaker, who explains that he has been misinformed; the Queen of the Night holds her power by use of ignorance, superstition and malice, and Sarastro intends to bring her up in wisdom and virtue. Sarastro leads Pamina into the Temple, then admits Tamino and introduces him to the priests, who consent to his undergoing the trials necessary to prove him worthy of Pamina, with whom he has fallen in love and she with him. Tamino and Papageno set off together, first being subjected to a period of silence in an underground vault (trial by earth), then wandering about (trial by air) until they meet Pamina. She has, meanwhile, been visited by her mother who gives her a dagger to kill Sarastro. Sarastro appears and punishes the Queen and her henchmen, Tamino and Pamina go off together to finish his probation. They arrive at a cave with a waterfall before the opening and a great fire inside. They pass through the water and fire and are then conducted into Sarastro’s court for triumphant reception into the mystic brotherhood.
Specific masonic references. Firstly, the overture and the grand finale are in the key of E-flat, in which the key signature in the written score is three flats arranged in a triangular form. The flats have a resemblance to a candle flame and are a clear allusion to the three lesser lights which burn in every lodge. (Mozart’s Masonic Funeral Music and music he wrote for Lodge use is also in E-flat, so that this is sometimes referred to as the Masonic key). Secondly, when Tamino is standing outside the Temple awaiting admission, Sarastro says to the priests, “Tamino, son of a king, is wandering by the north gate of our temple and wishes to divest himself of his veil [hoodwink] and look into the shrine of the great light.” The north is here significant, as the north is masonically termed a place of darkness. Third, at several places in the story, help and guidance are given by three boys, representing genii. They would presumably allude to the officers of the lodge (deacons & master of ceremonies?) who take charge of a candidate. Lastly, throughout, there are constant allusions to wisdom, virtue, fortitude, patience, charity, and the other virtues which are so much the subject of the masonic ritual.