"Bart Gets an Elephant" is the seventeenth episode of Season 5.
Bart wins a radio contest and has to choose between two prizes: ten thousand dollars or an elephant. Bart picks the elephant and names his pet Stampy. But when Marge and Homer plan to send the elephant away, Bart and Stampy run off together.
Marge wakes up and after seeing how messy the house is declares that everyone is to cancel their plans and help clean up. During the cleaning day Lisa is upset, as they are stuck inside while everyone is having fun. Homer tries to clean the basement by using the leaf blower and also using cleaning fluids which make him hallucinate. Later at the Simpsons' house, Bart (thinks) he wins a radio contest but it was only Grandpa. At the end of the day, the house is sparkling, Marge tells them they can do whatever they want now but the family is too exhausted. The next day Bart wins a KBBL radio contest after the station's DJs, Bill and Marty, call him up. They give Bart the choice of two prizes: $10,000 in cash or the "gag" prize: a full-grown African bush elephant. Bart unexpectedly picks the elephant, this surprises his parents as well as Bill and Marty, who (understandably) believed that no one would ever actually take the gag prize, and thus have no elephant to give away. Instead, they offer Bart the money and a variety of other prizes, all of which he refuses, saying that he only wants the elephant. Word spreads throughout town about Bill and Marty's refusal to give Bart the elephant, KBBL's ratings are at an all time low and the studio receives many angry letters and bombs, prompting their employer to give them a choice: either arrange for the delivery of the elephant, or lose their jobs to a DJ machine. Not wanting to lose their jobs, they select on the former option.
Bart names his new elephant Stampy and Homer ties him to a post in the backyard. Lisa complains that it's cruel to keep animals like elephants as prisoners, while Homer's concerned that Stampy will eat him out of house and home. In an effort to offset food costs, Bart and Homer exhibit Stampy by charging customers to see and ride him, but fail to earn enough to cover even one day's food bill. The customers all flee after Homer raises their prices to exorbitant levels. Homer declares they can't afford the elephant and must sell him, much to Bart's dismay. The family is visited by a representative of a game reserve, who says their acres of open land similar to the AfricanSavannah would be a good habitat for the elephant to live in. However, Homer immediately dismisses this after the representative explains that the family won't receive any money for Stampy since the reserve itself is a nonprofit organization.
A wildlife poacher named Mr. Blackheart then offers to buy Stampy. Homer wants to take the money, but Bart and Lisa are against the idea, especially after Mr. Blackheart openly admits to being an ivory dealer. Homer and Mr. Blackheart reach a deal, but Bart and Stampy run off, wreaking havoc throughout Springfield, and are soon nowhere to be found. The family begins searching and finds them at the Springfield Tar Pits, where Homer still plans to sell Stampy to the ivory dealer for the money. Bart and Lisa then ask if Homer would like to be sold to an ivory dealer himself, to which Homer responds positively, before finding out that he is stuck in one of the tar pits. Bart orders Stampy to free Homer, to which he does (after first pulling out Barney Gumble). A grateful Homer finally agrees to donate the elephant to the wildlife reserve.
While at the reserve, Stampy starts headbutting the other elephants, cheered on by Bart. When Marge expresses confusion by this, thinking that Stampy's unhappy, the representative explains that Stampy's likely very happy and explains further by pointing out how, in many ways, animals are a lot like humans: some animals act badly because they have had a hard life (such as from being mistreated) but, like some humans, some animals are just jerks (which he says while Homer is headbutting him, presumably still outraged over not getting any money).