Tom and Becky lost in the caves. Illustration from the 1876 edition by artist True Williams
Tom Sawyer, an orphan, lives with his Aunt Polly and his half-brother Sid in the fictional town of St. Petersburg, Missouri sometime in the 1840s. A fun-loving boy, Tom skips school to go swimming and is made to whitewash his aunt's fence for the entirety of the next day, Saturday, as punishment.
In one of the most famous scenes in American literature, Tom cleverly persuades the various neighborhood children to trade him small trinkets and treasures for the "privilege" of doing his tedious work, using reverse psychology to convince them it is an enjoyable activity. Tom later trades the trinkets with other students for various denominations of tickets, obtained at the local Sunday school for memorizing verses of Scripture; he cashes these in to the minister in order to win a much-coveted Bible offered to studious children as a prize, despite being one of the worst students in the Sunday school and knowing almost nothing of Scripture, eliciting envy from the students and a mixture of pride and shock from the adults.
Tom falls in love with Becky Thatcher, a new girl in town and the daughter of a prominent judge. Tom wins the admiration of the judge in church by obtaining the Bible as a prize, but reveals his ignorance when he cannot answer basic questions about Scripture. Tom pursues Becky, eventually persuading her to get "engaged" by kissing him. However, their romance soon collapses when she learns that Tom had been previously "engaged" to another schoolgirl, Amy Lawrence, and that Becky was not his first girlfriend.
Shortly after Becky shuns him, Tom accompanies Huckleberry Finn, a vagrant boy whom all the other boys admire, to a graveyard at midnight to perform a superstitious ritual designed to heal warts. At the graveyard, they witness a trio of body snatchers, Dr. Robinson, Muff Potter, and Injun Joe, robbing a grave. Muff Potter is drunk and eventually blacks out, while Injun Joe gets into a fight with Dr. Robinson and murders him. Injun Joe then appears to frame Muff Potter for the murder. Tom and Huckleberry Finn swear a blood oath not to tell anyone about the murder, fearing Injun Joe would somehow discover it was them and murder them in turn. Muff Potter is eventually jailed, assuming he committed the killing in an act of drunkenness and accepting of his guilt and fate.
Tom grows bored by school, and along with his best friend Joe Harper and Huckleberry Finn, they run away to Jackson's Island in the Mississippi river to begin life as "pirates." While enjoying their new-found freedom, they become aware that the community is sounding the river for their bodies, as the boys are missing and presumed dead. Tom sneaks back home one night to observe the commotion, and after a brief moment of remorse at his loved ones' suffering, he is struck by the grand idea of appearing at his own funeral. The trio later carries out this scheme, making a sensational and sudden appearance at church in the middle of their joint funeral service, winning the immense respect of their classmates for the stunt. Back in school, Tom regains Becky's favor after he nobly accepts the blame and caning punishment for a book she has ripped.
In court, Injun Joe pins the murder on Muff Potter, although Tom and Huckleberry Finn know he is innocent. At Potter's trial, Tom decides to defy his blood oath with Huck and speaks out against Injun Joe, who quickly escapes through a window before he can be apprehended. Henceforth, the boys live in constant fear of Joe's revenge on them for incriminating him.
Summer arrives, and Tom and Huck decide to hunt for buried treasure in a haunted house. After venturing upstairs, they hear a noise below, and peering through holes in the floor, they see the deaf-mute Spaniard who had showed up in the village some weeks before reveal himself to be Injun Joe. Speaking freely, Injun Joe and a companion plan to bury some stolen treasure of their own in the house. From their hiding spot, Tom and Huck wriggle with delight at the prospect of digging it up. However, by chance, the villains discover an even greater gold hoard buried in the hearth, and carry it off to a better secret hiding place. The boys are determined to find where it has gone, and one night, Huck spots them and follows them. He overhears Injun Joe's plans to break into the house of the wealthy Widow Douglas and mutilate her face, an act of revenge for her late husband, a justice of the peace, having once ordered him to be publicly whipped for vagrancy. Running to fetch help, Huck prevents the crime and requests his name not be made public, for fear of Injun Joe's retaliation, thus becoming an anonymous hero.
In the meantime, Tom goes on a picnic to McDougal's Cave with Becky and their classmates. However, Tom and Becky get lost and end up wandering in the extensive cave complex for the several days, facing starvation and dehydration. Becky becomes extremely dehydrated and weak, and Tom's search for a way out grows more desperate. He accidentally encounters Injun Joe in the caves one day, but is not seen by his nemesis. Eventually, Tom finds a way out, and they are joyfully welcomed back by their community. As a preventive measure, Judge Thatcher, Becky's father, has McDougal's Cave sealed off with an iron door. When Tom hears of the sealing two weeks later, he is horror-stricken, knowing that Injun Joe is still inside. He directs a posse to the cave, where they find Injun Joe's corpse just inside the sealed entrance, starved to death after having desperately consumed raw bats and candle stubs as a last resort. The place of his death, and specifically the in situ cup he used to collect water from a dripping stalactite, becomes a local tourist attraction. Tom and others in the town feel pity at the horribly cruel death, despite Injun Joe's wickedness, and a petition is started to the governor to posthumously pardon him.
A week later, having deduced from Injun Joe's presence at McDougal's Cave that the villain must have hidden the stolen gold inside, Tom takes Huck to the cave and they find the box of gold, the proceeds of which are invested for them. The Widow Douglas adopts Huck, but he finds the restrictions of a civilized home life painful, attempting to escape back to his vagrant life. Tom tricks him into thinking that he can later join Tom's new scheme of starting a robber band if he returns to the widow. Reluctantly, Huck agrees and goes back to the widow.