The book opens in the famously upright and self-righteous town of Hadleyburg, a community fiercely proud of its three generations of unblemished honesty. An embittered stranger, seeking total revenge against the town for a slight, devises an elaborate plot to corrupt its entire population. He leaves a heavy sack of gold coins with an old couple, accompanied by a letter stating the money belongs to an anonymous citizen who once showed him great kindness and saved him from ruin.
The letter explains that the rightful beneficiary can be identified by the specific remark he made to the stranger years ago, which is sealed inside the sack. If the town prefers a public inquiry, the details are to be published in the local paper. The old couple, struggling with poverty, momentarily entertain keeping the gold before the husband takes the document to the printing office. As the secret leaks and townspeople begin to reflect on who might have performed the noble deed, a wave of secret anxiety and moral collapse sweeps through Hadleyburg.
It soon emerges that the only man capable of such generosity was Barclay Goodson, a famously disliked cynic who has since died. Nineteen of the town's most prominent citizens, consumed by greed and financial desperation, each convince themselves through elaborate mental gymnastics that they were the secret benefactor. As the town waits for the public trial at the town-hall, widespread spending on credit plunges the residents into reckless financial commitments based on the anticipated forty-thousand-dollar windfall.
During the grand public assembly led by the Reverend Mr. Burgess, the anticipated test-remark is read, leading to a series of farcical exposures. Multiple prominent citizens step forward, each claiming the remark as their own, until the town-hall descends into chaotic hilarity. The climax arrives when the final document is opened, revealing that there was never any stranger, twenty-dollar gift, or gold at all—only gilded lead disks left by the vengeful traveler to thoroughly destroy the town's blinding vanity.
The final section of the volume reflects on human nature, the universality of moral weakness, and the subtle ways people rationalize dishonesty. Twain observes that virtue untested by fire is fragile and that the silent, collective lies of society far outweigh individual transgressions. The narrative concludes with the ruined town changing its name and motto, having learned a painful, permanent lesson about the true cost of unyielding human pride.