Nelson invites the whole of Bart's class to his birthday, but Bart and Martin convince the other kids not to go. Bart is forced to go to Nelson's birthday by Marge, and ends up becoming friends with Nelson.
Marge and Homer are making love in their room while playing a tape of their arguments so the kids will not come in. When a flying article of clothing hits the tape recorder and plays America's "A Horse with No Name", Bart and Lisa plan to come in. Bart ends up traumatized by the sight and is an emotional wreck the following day. While he's coping, Nelson coerces Bart and Milhouse for their lunch money but also invites him and the rest of the class to his upcoming birthday party. Although Bart convinces all his friends not to go to Nelson's birthday party—and coincidentally gets Groundskeeper Willie fired when he mistook "Hell, no! We won't show!" for "Hell, no! I won't mow!"—Marge forces him to attend.
After the party, Bart becomes Nelson's new best friend and under Nelson's protection no one dares to mess with Bart. There is only one drawback to his newfound friend/bodyguard; he can no longer pal around with Milhouse because Nelson has never had a best friend before and is overly protective and jealous. Eventually, Nelson discovers that Bart had been playing with Milhouse, which leads him to no longer consider Bart a friend. He eventually decides to forgive Bart, however Bart tells Nelson that he thinks he is a psycho. Later, during a field trip to some tidepools, Nelson confronts Bart in a cave, telling Bart that he is a bad friend.
Suddenly, high tide comes and Nelson saves Bart (but only because they were field trip buddies). Later Bart goes home and remembers the good times he had with Nelson while hugging a "Nelson vest" he had received (a Brokeback Mountain movie reference). Nelson rides by on a bike and shouts "Haw Haw! I touched your heart!"
Homer finds himself hooked on one of LIsa's fantasy books, choosing to read an "Angelica Button" book to Lisa, as opposed to snuggling with Marge. Homer eventually reads ahead when Lisa spends a night out at a friend's house and finds that one of the characters, Headmaster Greystash, is killed while trying to save Angelica. Upon hearing that Greystash dying would be the end of Lisa's childhood, Homer is unable to bring himself to read the last chapter to Lisa, and improvises a happy ending, instead involving Greystash defeating the evil wizard, Angelica managing to get out of the trap and they ride in a sports car Greystash had conjured to a castle.
Afterwards, Lisa reads the real ending and chooses that Homer's ending was better. During the credits, Homer is seen at Moe's Tavern, still mourning the loss of the Headmaster ("No man should have to outlive his fictional wizard!") while Moe, Carl and Lenny look at him.