As Peter and Lois discuss a family trip to Maine, Chris suddenly enters the kitchen, and alerts his parents that he has been suspended by his principal for telling an inappropriate joke. Assuring his principal it will not ever happen again, Chris reveals that it was actually Quagmire who told him the joke in the first place. Deciding to confront Quagmire at the Drunken Clam later that day, Peter finds the joke to be hilarious and accidentally soils himself. Quagmire and Joe soon discover that Peter actually does so everytime they tell him the joke, and the two set out to continually make him soil himself. Tired of their antics, Peter decides to wear Quagmire's pants to the bar the next day, preventing them from making him laugh. Going on to question where Quagmire heard the dirty joke in the first place, he reveals that it was actually Bruce who told him the joke. Locating Bruce at his job at the bowling alley, the group eventually discover that the joke originated with a Virginia bar tender. Setting out from Quahog, along with Bonnie and Lois, expecting to go on vacation to Maine, Quagmire distracts the two women, as they begin on their journey to Virginia instead. The group then enters the local bar in Stoolbend, Virginia, and discover that it was actually Cleveland who told Gus the Bartender the joke. Asking who Cleveland heard it from, he reveals that it was a bellhop named Sal Russo who told him the dirty joke. The group, along with Cleveland, then set out on the road once more to Washington, D.C., but are soon attacked by a black vehicle, who fires gunshots at them, in an attempt to stop them from learning the joke's origin. The group then arrive at a Washington hotel, and locate Sal, who is reluctant to tell them where he heard it from, and races away on a handcart through Washington. Losing track of Sal, they are soon captured by several men in black suits, who beat them with their guns.
Kidnapped and thrown on a plane, they soon approach an island and land, being lead by the men in suits through the jungle wilderness to a large stone temple. The Dean of the Secret Order of Dirty Joke Writers then appears from the shadows, and leads the group into a large library with the world's greatest geniuses studying inside. The Dean then leads the four on a tour, eventually taking them to a dark room. Revealing that they are not permitted to leave the island, now that they know the source of all the world's dirty jokes, they are locked in a jail cell. In an attempt to escape, Peter stabs Cleveland with a pencil, requiring a guard to unlock their cell. The group then escape, and are confronted by the Dean, and his armed guards immediately. As they are about to be shot by the guards, a man revealing that he has written the world's greatest dirty joke suddenly dies, with Peter stealing the joke that he had written on a small paper. Escaping on a plane, the group soon watch the castle be blown to pieces in a huge fireball, after it is set on fire by a candle that Peter had thrown at a curtain. Peter, Joe, Cleveland and Quagmire then fly off into the sunset, and set back to Quahog, before finding out the supposed greatest joke ever written is "Guess what? Chicken butt".