"With the help of a radio talk show host, Mayor Quimby is pressured into releasing Sideshow Bob from prison. Once out, Bob promptly runs against the mayor and wins. Bart and Lisa set out to prove Mayor Bob didn't win legally."

Sideshow Bob calls up Birch Barlow, a local right-wing talk show host, stating that he is being treated unfairly in prison. Thanks to Barlow, all of Springfield sympathizes with Bob. Pressured by protests, Mayor Quimby releases Bob.

At a Springfield Republican meeting, Bob announces his candidacy for mayor of Springfield. Determined to keep the psychopath from becoming mayor, Bart and Lisa help campaign for Quimby. Quimby helps get the old folks' votes by naming a new expressway the "Matlock Expressway". Bob then steals the support of the old folks by promising to build the Matlock Expressway and spending the rest of the afternoon listening to all of their problems. Unfortunately, at a televised debate hosted by Larry King, and broadcast on FOX, Quimby has the flu and tries to counteract it with extra-drowsy flu medication. Springfield casts their votes for mayor and the results are 100% for Bob and 1% for Quimby (and there is a one percent margin of error).

The next morning, the Simpsons wake up to construction occurring outside (which Homer mistakes for the Rapture). Bob informs the family that the Simpsons' house is in the way of the new Matlock Expressway and that it will be demolished in 72 hours, along with any remaining Simpsons. Bart and Lisa begin to suspect that Bob somehow cheated in the election. Lisa goes through all the voter records but that does not help. Under Bob's orders, Bart is also transferred to the kindergarten classroom (which he actually enjoys). While Lisa reviews the records, someone leaves a message for her. Bart and Lisa go to a parking garage to meet with the whistle blower, who turns out to be Waylon Smithers, Jr. who, while hating to go behind Mr. Burns back, feels that some of the laws Bob passed conflict with his "choice of lifestyle." He gives them one name of a person who voted for Bob as a hint, and the two children soon discover that virtually every single person (and many pets) who voted for him was dead, some for centuries. Of course, dead people and animals are not eligible to vote.

At a trial, an angry Bart and Lisa appeal to Bob's ego and into confessing his crime by saying he isn't intelligent enough to have pulled it off and that he was just Barlow's lackey. Not being one to be belittled Bob angrily confesses his crimes and even produces the evidence, only realizing the mistake he made when Judge Snyder calls for him to be arrested. He is thrown into a minimum security prison, thus managing to let the Simpsons have their house back, letting Quimby regain his term as mayor, and putting Bart back into the fourth grade (much to his dismay).