At the First Church of Springfield, very few people are present at Reverend Lovejoy's service at the fourth Sunday of Advent and his wife Helen calls him afterwards to meet a "fan club" which was actually an intervention by Ned Flanders, Agnes Skinner, Sideshow Mel and Lovejoy's boss The Parson (a caricature of Bing Crosby) who introduce him to the Patriarch. They tell him he needs to bring more people to the church, and he assures them he's going to do so because Springfield is a good Christian community.
Meanwhile, a pagan festival is held in town, with the Simpson family and the others attending where Theo Jansen shows his feature attraction the Strandbeest, a wind-powered vehicle.
However, the Strandbeest goes wild due to the stronger winds and tramples Krusty the Clown, who was ice-skating with his daughter Sophie, whom he only sees during the holidays. At Springfield General Hospital, Krusty (who's Jewish) tries to bond with his daughter but finds out her mother raised her Christian and she wants to celebrate Christmas. Seeing the discomfort, Marge invites the pair to spend Christmas with them.
Back at home, Marge brings Maggie a Gnome in Your Home (a parody of The Elf on the Shelf), a gnome that is supposed to watch over her all the time and tell Santa Claus what she's been doing, He doesn't sleep and never shuts his eyes and Homer tells her that if she isn't good, he'll nibble off her fingers. Krusty arrives at the home but brings in a TV crew to record it as a television special, angering Sophie to the point of sending him away.
Meanwhile, Reverend Lovejoy tries to convince Dewey Largo and Apu Nahasapeemapetilon to convert but fails. So he goes to Moe's Tavern and manages to convert Krusty who does so after mistaking Snake being tased through the window for an image of Jesus Christ.
That night, Maggie has a nightmare in which the Gnome attacks Maggie after Homer moves her crib closer to him. He talks to her, spits out finger tips and scares her so much she finds herself at the North Pole where she meets Santa Claus, Jack Frost, the Abominable Snowman and Wayne Gretzky. They tell her they'll defeat the Gnome, but he has a gun and they all run off. Maggie enters a cave which turns into the Gnome's head and eats her. Maggie is woken up from her dream by Marge to find it's Christmas. Marge says the Gnome told her she has been good, and to her surprise, and horror, she says they'll leave him in her room all year around.
At the church, Lovejoy introduces the newly converted Krusty, and Sophie, seeing the change, is happy. Back at home, Maggie opens her present to find out it's a Mrs. Gnome in Your Home.
In their bedroom that night, Marge surprises Homer by wearing a "Christmas costume", but as they get into bed, they find that under the covers are parts from Mr. and Mrs. Gnome in Your Home, all cut to smithereens, while Maggie finally goes to sleep happy.
Next, Sideshow Mel introduces the Krusty the Clown Sober Contemplation Hour, where Krusty shows how much the conversion has changed him and his show, including Itchy and Scratchy, to the surprise and disappointment of the kids in the audience.
Krusty gets ready for his baptismal in a river, and while approaching Lovejoy, he cracks the ice and falls underneath. In a hallucination due to a lack of oxygen underwater, he is visited by the ghost of his father Rabbi Hyman Krustofsky and that of his first agent (who initially appear in the form of Olaf and Sven from Frozen) in an ice castle. He talks with his father about his conversion and his role as dad. He is saved by Lovejoy who is praised as a savior and many people return to church for his service. Krusty goes back to being Jewish.
In the final montage, Sideshow Mel's wife leaves him and Maggie destroys more Gnomes.
During the credits in the afterlife, the Christian version of God and the Jewish version of God argue over if Krusty by going underwater received the baptismal and became a Christian. They are interrupted by a drunk Ahura Mazda: God of Zoroastrianism who had been referenced earlier in the episode. Krusty and Sophie are singing while being carried by the Strandbeest on the snow.
- The title is a reference to The Nightmare Before Christmas.