At church, Reverend Lovejoy orders Bart and Milhouse to clean the pipes of the organ, after Bart pulls a prank by changing the opening hymn to "In-A-Gadda-Da-Vida" by Iron Butterfly. During a discussion between the two boys, Bart proclaims there is no such thing as a soul and for $5 agrees to sell his to Milhouse in the form of a piece of paper reading "Bart Simpson's soul". Lisa warns Bart that he will regret selling his soul, but he dismisses her fears. Soon, Bart begins to suspect he really did lose his soul after experiencing unusual phenomena, and sets out to retrieve it.
Bart attempts to get his soul back from Milhouse, who refuses to return it for less than $50. After having a nightmare and being taunted by Lisa, Bart again desperately tries to persuade Milhouse to return the paper. However, Milhouse tells Bart that he traded the paper to Comic Book Guy at the Android's Dungeon.
The following morning, Comic Book Guy tells Bart that he no longer has the piece of paper but refuses to reveal to whom he sold it. Bart walks home in the rain, then in his room he prays to God for his soul. Suddenly, a piece of paper with the words "Bart Simpson's soul" floats down from above. Bart discovers that Lisa had purchased the piece of paper. While she explains philosophers' opinions on the human soul, Bart happily eats up the piece of paper.
In the subplot, Moe decides to expand his customer base by turning his tavern into a family restaurant. The stress of running the business by himself ultimately unnerves him and he soon snaps at a little girl. The restaurant is a failure, forcing Moe to revert to a run-down tavern.