Homer becomes a masked vigilante known as the "The Pie Man". He uses pies in order to stop crime in the town of Springfield.
Homer watches a commercial about a contest that will allow the winner, the finder of a Golden Ticket, a trip to "Farmer Billy's Bacon Factory", and is intrigued by the commercial. Although Homer buys a surplus of bacon from the Kwik-E-Mart, he is only able to find a silver ticket, which allows him to judge the upcoming placement competition at the county fair. At the fair, Lisa's entry in the place setting competition is wrecked by The Rich Texan, making her cry. This angers Homer, who plans to teach the Rich Texan a lesson. Recalling a warning from Chief Wiggum that he will be arrested if he commits another felony assault, Homer disguises himself as a masked superhero, "The Pie Man", and throws a pie straight into the Rich Texan's face, leaving him humiliated and the crowd laughing.
The next day, Lisa is seen drawing her favorite superhero - Pie Man. After Homer hears that the Comic Book Guy has ripped off Bart and Milhouse, he arrives as the Pie Man (with a newer look) and throws a pie in his face. Nichelle Nichols (Lieutenant Uhura) of Star Trek, whom Jeffery Albertson invited for tea and some chit chat, suddenly shows up and is turned off by the pie on his face. This humiliates him in front of the kids and he runs away in tears. The next day, the family watches the news and discovers that the Springfield Children's Hospital is going to be turned into a cosmetic surgery clinic. Homer worries about the plight of the sick children.
That same evening, two sick and coughing children are pushed away from the hospital by Mayor Quimby. Chief Wiggum, believing that the Pie Man must be stopped because he does not do bike safety lectures, plans to capture him at the event. The Pie Man shows up, pie at the ready. Lenny (who tried to warn Homer), the Pie Man fans, and the other crowd members run for safety because the cops open fire, with Lou hitting Homer in the arm. Homer manages to escape rather flamboyantly. At home, Lisa enters the kitchen and sees Homer, still disguised as Pie Man. Lisa figures out that he is actually her father. Homer, unmasked, brings blindfolded Lisa to his Pie Cave (a.k.a. the basement) but Lisa is not surprised. He promises Lisa (who does not want him to get hurt again) that he will stop his pie avenging. Yet the next day at the power plant's employee cafeteria, Mr. Burns is whipping Lenny and Carl, so that they will eat faster and return to work, and docks Homer a day's pay for being late and bald. As Homer goes through the serving line, he imagines the desserts talking to him, with the pies asking to be thrown and a piece of cake urging Homer to remember his promise to Lisa. Even though he remembers his promise to Lisa, Homer makes another appearance as Pie Man when Mr. Burns shuts down the employee showers and tells them he has sold their clothes. Pie Man arrives, pies Burns in the face, and flees.
However, after watching the video surveillance cameras, Burns sees that Pie Man is tired from his escape and falls asleep on a couch. Turning around, he sees Pie Man sleeping on the couch in the room. Burns and Smithers lock him in the employee detention center, and unmask him. Burns makes Homer his personal hitman and threatens to reveal his identity to the rest of the city if he does not comply (Homer goes along with it because he doesn't want to wind up doing community service). His first task is to pie himself, then a girl scout. Mr. Burns and Smithers come to the town square in disguise to Homer to show that his next assignment is to throw a pie in the face of the Tibetan Buddhism spiritual teacher, the Dalai Lama (because according to Mr. Burns "all his talk of peace and love is honking off my Red Chinese masters"). However, at the Dalai Lama's show, Homer - disguised as Pie Man - can not go through with it since Lisa is present and is Buddhist herself. He reveals his identity to the public, but no one believes he could possibly be Pie Man; they all think he is just too dumb and greedy. The Dalai Lama then flies out of the building safely, and to give another lecture at Buffalo, New York. Pie Man is now free from Mr. Burns' control for good.
Later, we see Homer and Marge snuggling in bed, and Marge says that she believed that Homer was the Pie Man--she points out that it was clearly him in the costume, and says, "You'd have to be an idiot not to see it from the start." While she laughs at this, Homer makes his way to the roof and states that whenever injustice and evil rears its head, Pie Man will return. Bart joins him as his trusty sidekick, the Cupcake Kid. However, they are soon subjected to a great injustice by Marge, by making them clean out the gutter, much to their dismay.