Marge drives Bart and Lisa to school in Homer's car when the children begin fighting. When Marge tries to stop the children from fighting, she crashes into Hans Moleman's car, who is suffocated by the airbag. Later at school, Bart is shocked to find his seat taken by a new student, named Donny, who was recently kicked out of his former school, which his first in-episode words defame. Donny is a lot like Bart, but with a sharper edge and more grace. After Donny throws massive amounts of garbage at the school wall, Bart begins to feel like he is losing his popularity. While trying to imitate Donny, Bart ends up humiliating himself. Feeling his social rank among his peers slipping, Bart sulks.
Meanwhile, Homer has taken his car to get fixed. The Wiseguy informs him of a loaner car, resembling the Cadillac CTS, that he could use in the meantime. The loaner car is significantly better than Homer's old car, and he embraces it, and begins driving it everywhere. One added feature is that it can create a miniature thunderstorm within the vehicle, which happens when "the heater fights the air conditioner."
The following day, to prove to Donny that he is the head mischief-maker in the school, Bart plays a prank on Principal Skinner, employing magnets and metal sole pads in Skinner's shoes. While on the school stage, the magnets cause Skinner to dance involuntarily and uncontrollably, and ultimately be hurled outside of the school into a container filled with old retainers. Bart regains the respect and admiration of his peers, but when Skinner attempts to find who is responsible, Donny takes the blame for Bart's prank, leading Bart to accept him as a friend.
However, when Skinner takes Donny to his office, Donny is revealed to be in fact an informant hired by Principal Skinner and Superintendent Chalmers to get Bart suspended — the first informant on Bart to go undiscovered (after failed attempts utilizing Üter Zörker, Ralph Wiggum and "Doug the hip guidance counselor"). Blissfully unaware of the new kid's other side, Bart invites Donny into his clique alongside Nelson Muntz and Milhouse Van Houten, and they plot school pranks. To signify Donny's entrance into the group, Bart rewards him with Blue Vine licorice sticks, which he claims are only sold in Europe and turn the eater's tongue blue, and the now-augmented group begins their friendship by spraying Lisa (and each other) with juice.
Homer takes Marge out on a romantic evening cruise. Then the Wiseguy calls Homer, informing him that his old car is ready to be picked up. Homer, however, refuses to give up his luxury car. At the school, Bart is perplexed when Skinner repeatedly anticipates and foils his pranks. Groundskeeper Willie informs Bart that a snitch is among them, but after a lengthy montage depicting an ultimately failed chase after the rat, Bart wrongly suspects Milhouse, not noticing Donny's apparent nervousness. With the aid of Nelson and Donny, Bart has Milhouse imprisoned in a locker, which Cletus subsequently mistakes for an outhouse using Milhouse as a "robo-potty." With Milhouse indisposed, Bart plans a final prank on Skinner involving pelting his house with ostrich eggs.
The next day, while helping Skinner hang up a banner (which ironically reads “SPRINGFIELD ELEMENTARY: PRANK-FREE FOR 14 DAYS”), Bart notices that Skinner's tongue is blue. Bart figures out that the snitch is Donny, who had given Skinner the Blue Vines. While driving past the car dealer with Lisa, Homer sees the Wiseguy selling his car for $99. Homer realizes that his car is like his child and furiously barges into the scene to take it back, abandoning the loaner car and almost leaving Lisa, whom he mistakenly calls Maggie, behind.
At midnight, Bart, Nelson and Donny go to the school storage building, where Willie lets them in. Donny asks why the change in plans was necessitated, and Bart promptly denounces a nervous Donny as the rat and Nelson grabs him. Donny pleads with Bart, explaining how he was claimed from an orphanage in Shelbyville by Skinner and Chalmers. Touched but unmoved, Bart still plans to place him in Skinner's office, where he and Nelson will mix Diet Coke and Mentos, of which they have a huge amount. They are interrupted by the arrival of Superintendent Chalmers, Principal Skinner (toting a video camera), and Willie, who has snitched on Bart in exchange for something he could never give him: an elementary school diploma. After Nelson runs out the door, Chalmers tells Bart he will be sent to the toughest juvenile detention center there is (disregarding his earlier statement that Bart's punishment will be 10 days' suspension from school, the stiffest disciplinary action that can legally be taken against him). Donny then pities Bart, who was the only person who ever cared for him. As Skinner leads Bart away, Donny (who became guilty after Skinner happily stated that "he can happily live the rest of his life knowing he betrayed the one boy who actually cared about him") shoves the crates of Mentos into the Diet Coke, causing the fizzy explosion. The two boys escape through the roof as Skinner, Chalmers, and Willie are caught in the explosion. Bart and Donny shake hands and Donny leaves, telling Bart he will always remember their friendship, and they promise to meet up with each other sometime in the future. The episode ends with Ralph in a trash can as a rat runs across a fence, and Ralph cheerfully remarks "the rat symbolizes obviousness!" explicitly referring to the very last scene of The Departed.