A financial crisis in Springfield causes the sale of many houses and the release of all low-level criminals from Springfield Penitentiary, including a man named Walt Warren. Walt purchases a house next door to the Simpson family (where The Winfields and Ruth and Laura Powers used to live), and he immediately charms the neighborhood. However, Bart is convinced that Walt is Sideshow Bob in disguise, because they have the same voice. He tries several times to find proof, but fails. Marge convinces him otherwise by taking him to visit the penitentiary, where they see Bob locked in a padded cell, wearing a straitjacket and writing "Bart Simpson Will Die!" on the walls. A reassured Bart decides to go to a baseball game with Walt. However, Bart's initial instincts prove right when "Walt" removes his small shoes to show his long feet folded inside, revealing himself to be Sideshow Bob. Bob restrains Bart in the car and gags him with duct tape, planning to take him to Five Corners, a location where five states meet, to kill him.
Meanwhile, the real Walt Warren escapes prison while bearing Bob's hair and face and comes to the Simpsons' home. At first, everyone thinks Bob has escaped prison, but Walt's short feet (which was also used as a clue in "Krusty Gets Busted" to clear Krusty's name for robbing the Kwik-E-Mart) reveal his true identity. Walt explains that he and Bob were cellmates and, prior to Walt's release, Bob drugged him and performed a transplant to switch their faces. The transplant left Walt unable to talk properly, and his garbled speech led the guards to put him in the padded cell. He wrote his message on the wall as a warning, but it was misinterpreted as a threat. Walt and the Simpsons immediately go after Bob, knowing that Bart's life is in danger. Meanwhile, a waitress at a roadside diner becomes infatuated with Bob-as-Walt until Bob's new face peels off. Amidst a distraction outside the diner, Homer, Marge, and Lisa travel to Mexico in search of Bart while Walt gets away and continues to the Five Corners to save Bart.
At Five Corners, Bob intends to kill Bart in such a way that the crime takes place in five separate states, thus making it impossible to prosecute. Bart stalls by repeatedly jumping into the same state as Bob until Walt arrives. Walt and Bob struggle over the gun, but just before Bob can fire on either Walt or Bart, Chief Wiggum and the Springfield Police Department arrive to arrest Bob, having been tipped off by Bart. Bob jumps into the other states in order to escape their jurisdiction, only to be promptly confronted by police from each state, and he is taken into custody by officers with a strong New Jersey accent. His house is bought by Ned Flanders' cousin Ted, and Homer groans at the realization that he now lives next door to two Flanders families. The Sideshow Bob leitmotif first introduced in the episode "Cape Feare" plays over the credits.