Nuremberg, 16th century. At St. Katherine's Church, the visiting young knight Walther von Stolzing approaches Eva, daughter of the wealthy goldsmith Pogner, who is attending mass with her companion, Magdalene. Eva tells her admirer that she is to be engaged the following day to the winner of a song contest held by the local guild of mastersingers. David, Magdalene's sweetheart and apprentice to the cobbler and mastersinger Hans Sachs, explains the rules of song composing to Walther, who is surprised by the complicated ins and outs of mastersinging. Meanwhile David's fellow apprentices set up for a preliminary trial singing. The masters arrive, including Eva's father, and Walther expresses his desire to become a mastersinger in order to ask for Eva's hand. The town clerk Beckmesser, a spiteful pedant who also wants to marry Eva, is immediately suspicious of the young knight. As proof that tradesmen value art, Pogner offers his daughter's hand as the prize for the next day's contest and explains that she can reject the winner, but must marry a mastersinger or can marry no one. Walther introduces himself and describes his natural, self-taught methods of musical composition, provoking mocking comments from Beckmesser. For his trial song, Walther sings an impulsive tune in praise of love and spring, breaking many of the masters' rules. Beckmesser vigorously keeps a count of his errors. Rejected by the masters, Walther leaves, while Sachs wonders about the unexpected appeal of Walther's song.
That evening in front of Pogner's house, David tells Magdalene about Walther's misfortune and Eva gets the disappointing news from Magdalene. Across the street, Sachs sits down to work in his doorway, but the memory of Walther's song distracts him. Eva appears, hoping to learn more about the knight's trial. When Sachs mentions that Beckmesser hopes to win her the next day, she suggests she wouldn't be unhappy if Sachs himself won the contest. Sachs, who has known Eva since she was a child, responds with paternal affection. Asked about Walther, he pretends to disapprove of the young man, which leads Eva to reveal her true feelings and to run off. In the street, she is met by Walther who convinces her to elope. The two hide as a night watchman passes. Sachs, who has overheard their conversation, decides to help the lovers but prevent their flight. He lights the street with a lantern, forcing Eva and Walther to stay put. Meanwhile Beckmesser arrives to serenade Eva. As he is about to begin, Sachs launches into a cheerful cobbler's song, much to the clerk's irritation, claiming he needs to finish his work. They agree that both would make progress if Beckmesser were to sing while Sachs marked any broken rules of style with his cobbler's hammer. Beckmesser finally sings his song, directing it at Magdalene who is impersonating Eva at a window of Pogner's house. Sachs frequently interrupts with hammer strokes, to Beckmesser's mounting anger. Walther and Eva observe the scene from their hiding place, bewildered at first, then amused. Confusion increases when David appears and attacks Beckmesser for apparently wooing Magdalene. Finally the night-shirted neighbors, roused from sleep, join in the general tumult until the sound of the night watchman's horn disperses them. Pogner leads Eva inside while Sachs drags Walther and David into his shop. The night watchman passes through the suddenly deserted street.
The next morning in Sachs's workshop, David apologizes for his unruly behavior. Alone, Sachs reflects on the world's madness. Walther arrives to tell Sachs of a wondrous dream he had. Recognizing a potential prize song, Sachs takes down the words and helps Walther to fashion them according to the rules of mastersinging. When they leave to dress for the contest, Beckmesser appears. He notices Walther's poem and, mistaking it for one of Sachs's own, pockets it. The returning cobbler tells him to keep it. Certain of his victory with a song written by Sachs, Beckmesser leaves. Now Eva arrives, pretending there is something wrong with her shoe. Walther returns, dressed for the festival, and repeats his prize song for her. Eva is torn between her love for Walther and her affection for Sachs, but the older man turns her towards the younger. When Magdalene arrives, Sachs promotes David to journeyman and asks Eva to bless the new song. All five reflect on their happiness—Sachs's tinged with gentle regret—then leave for the contest.
Guilds and citizens assemble in a meadow outside the city. The masters enter and the people cheer Sachs, who responds with a moving address in praise of art and the coming contest. Beckmesser is the first to sing. Nervously trying to fit Walther's verses to his own music he makes nonsense of the words, earning laughter from the crowd. He furiously turns on Sachs and runs off. Walther then steps forward and delivers the song. Entranced, the people proclaim him the winner, but Walther refuses the masters' necklace. Sachs convinces him to accept—tradition and its upholders must be honored, as must those who create innovation. Youth and age are reconciled, Walther has won Eva, and the people once again hail Sachs.