Thanks to 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, in a slight reference to Douglas Adams' "The Hitchhiker's Guide to the Galaxy", 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 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 (though earlier, Homer is shown to vote for Bob because of his support of killing Selma, and Krusty is shown to vote for Bob because of the tax-cut policy he offered). Of course, dead people and animals are not eligible to vote.
At a trial, an angry Bart and Lisa appeal to Bobs 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).
On the original 1994 airing of the episode, the episode aired with the common title-driveway-couch-credits opening, while using the Eyeless Family couch gag from Boy-Scoutz 'n the Hood. However, on its sole 1995 repeat and on the Season 6 DVD, it went right from the title into the credits, while also using the Season 3 version of the theme song, despite being a Season 6 episode. In syndication, the episode aired instead with the infamous Duplicate Family couch gag, making it longer than the 1995 opening, but shorter than the 1994 opening. It is currently unknown why this change occurred.