"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.
During cleaning day at the Simpsons' house, 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 picks the elephant. This surprises 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 an elephant, prompting their employer to give them a choice: either arrange for the delivery of an elephant, or lose their jobs to a DJ machine. 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 is cruel to keep an animal like an elephant as a pet like that, 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's 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 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've 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).