Former criminal Sideshow Bob is declared a changed man by Reverend Lovejoy and released from prison on a work program, despite the protests of Bart. Bob is surprised to be taken into the care of his brother Cecil as the two had previously not spoken for ten years. A flashback reveals the cause of this rift: Cecil had auditioned to become the new sidekick for Krusty the Clown, a job he had long desired, but Bob, who had not originally intended to be the sidekick, was chosen instead. Cecil, who is Springfield's chief hydrological and hydrodynamical engineer, employs Bob to supervise the construction of a hydroelectric dam in a river near Springfield, while Bart, believing that Bob is still evil, continuously follows him around. Bob begins to become intensely annoyed by Bart's intrusions into his personal life and the dam's incompetent laborers (Cletus and his family), and he expresses a desire to see the dam burst and obliterate Springfield.
Meanwhile, Bart enlists Lisa to help find out what Sideshow Bob is up to, but only ends up being discovered rummaging in Bob's trash and angrily escorted home by him. They finally decide to search in Bob's trailer at the dam construction site, and discover a briefcase full of cash. On being interrupted by Bob, the children run and hide inside the dam's turbine room, but are cornered. When confronted with the money, Bob denies knowing anything about it, stating that he's putting up his finances to build the dam walls out of concrete, but is distraught to see the walls empty and poorly constructed. The kids then believe that Bob is cutting back on construction materials by embezzling the money for himself, but Cecil shows up with a gun and reveals that he is the one who embezzled the money; now he plans on framing Bob and using him as a scapegoat when the poorly constructed dam collapses. He officially declares his greed of the money motivated him to enact his plan, though he privately admits to Bob that his true motivation was because of Bob being chosen as Krusty's sidekick instead of Cecil. Without hesitation, Cecil locks Bob, Bart and Lisa in the dam and prepares to blow it up, taking the money with him.
Deciding to work together, Bart, Lisa, and Bob escape and try to save the dam. While Lisa and Bob set about defusing Cecil's dynamite, Bart jumps at Cecil before he can press the plunger. Cecil attempts to swat him off with the briefcase of money, but the case bursts open and the money is lost. Cecil manages to throw Bart off the cliff, declaring he will kill Bart as Bob never could; ironically, Bob grabs the cord of the dynamite and dives down in an effort to save him. As the two dangle down the side of the dam, Bob decides to cut the cord on the dynamite in an act of self-sacrifice to prevent Cecil from destroying the town, but his and Bart's perilous fall is broken by a conveniently placed pipe.
The police arrive and Cecil is immediately arrested. Bob gloats over his victory, having gained the respect from Bart and Lisa, who now believed that Bob has truly changed. Unfortunately, Chief Wiggum suddenly arrives and arrests Bob, believing him to be involved in the plot as well, despite Bart and Lisa's protests. As they are taken away, Cecil tricks Bob into swearing revenge on Bart and incriminating himself. Upon realizing that he just made Bart his enemy again, Bob gets angry at Cecil for it. Just after the brothers are taken away, the dam crumbles and releases a torrent of water on Springfield, only to do apparently minimal damage. Wiggum muses on the evil the brothers could concoct while locked up together; in reality, the brothers merely continue to bicker childishly, as Bob is still angry at Cecil for making Bart his nemesis again.