The story begins in fictional St. Petersburg, Missouri (based on the actual town of Hannibal, Missouri), on the shore of the Mississippi River "forty to fifty years ago" (the novel having been published in 1884). Huckleberry "Huck" Finn (the protagonist and first-person narrator) and his friend, Thomas "Tom" Sawyer, have each come into a considerable sum of money as a result of their earlier adventures (detailed in The Adventures of Tom Sawyer). Huck explains how he is placed under the guardianship of the Widow Douglas, who, together with her stringent sister, Miss Watson, are attempting to "sivilize" him and teach him religion. Finding civilized life confining, his spirits are raised somewhat when Tom Sawyer helps him to escape one night past Miss Watson's slave Jim, to meet up with Tom's gang of self-proclaimed "robbers." Just as the gang's activities begin to bore Huck, he is suddenly interrupted by the reappearance of his shiftless father, "Pap", an abusive alcoholic. Knowing that Pap would only spend the money on alcohol, Huck is successful in preventing Pap from acquiring his fortune; however, Pap kidnaps Huck and leaves town with him.
In Illinois and on Jackson's Island
Pap forcibly moves Huck to his isolated cabin in the woods along the Illinois shoreline. Due to Pap's drunken violence and imprisonment of Huck inside the cabin, Huck, during one of his father's absences, elaborately fakes his own death, escapes the cabin, and sets off down river. He settles comfortably, on Jackson's Island. Here, Huck reunites with Jim, Miss Watson's slave. Jim has also run away after he overheard Miss Watson planning to sell him "down the river" to presumably more brutal owners. Jim plans to make his way to the town of Cairo in Illinois, a free state, so that he can later buy the rest of his enslaved family's freedom. At first, Huck is conflicted about the sin and crime of supporting a runaway slave, but as the two talk in depth and bond over their mutually held superstitions, Huck emotionally connects with Jim, who increasingly becomes Huck's close friend and guardian. After heavy flooding on the river, the two find a raft (which they keep) as well as an entire house floating on the river. Entering the house to seek loot, Jim finds the naked body of a dead man lying on the floor, shot in the back. He prevents Huck from viewing the corpse.
To find out the latest news in town, Huck dresses as a girl and enters the house of Judith Loftus, a woman new to the area. Huck learns from her about the news of his own supposed murder; Pap was initially blamed, but since Jim ran away he is also a suspect and a reward for Jim's capture has initiated a manhunt. Mrs. Loftus becomes increasingly suspicious that Huck is a boy, finally proving it by a series of tests. Once he is exposed, she nevertheless allows him to leave her home without commotion, not realizing that he is the allegedly murdered boy they have just been discussing. Huck returns to Jim to tell him the news and that a search party is coming to Jackson's Island that very night. The two hastily load up the raft and depart.
After a while, Huck and Jim come across a grounded steamship. Searching it, they stumble upon two thieves discussing murdering a third, but they flee before being noticed. They are later separated in a fog, making Jim intensely anxious, and when they reunite, Huck tricks Jim into thinking he dreamed the entire incident. Jim is not deceived for long, and is deeply hurt that his friend should have teased him so mercilessly. Huck becomes remorseful and apologizes to Jim, though his conscience troubles him about humbling himself to a black man.
In Kentucky: the Grangerfords and Shepherdsons
Travelling onward, Huck and Jim's raft is struck by a passing steamship, again separating the two. Huck is given shelter on the Kentucky side of the river by the Grangerfords, an aristocratic family. He befriends Buck Grangerford, a boy about his age, and learns that the Grangerfords are engaged in a 30-year blood feud against another family, the Shepherdsons. The Grangerfords and Shepherdsons go to the same church, which ironically preaches brotherly love. The vendetta finally comes to a head when Buck's older sister elopes with a member of the Shepherdson clan. In the resulting conflict, all the Grangerford males from this branch of the family are shot and killed, including Buck, whose horrific murder Huck witnesses. He is immensely relieved to be reunited with Jim, who has since recovered and repaired the raft.
In Arkansas: the duke and the king
Near the Arkansas-Missouri-Tennessee border, Jim and Huck take two on-the-run grifters aboard the raft. The younger man, who is about thirty, introduces himself as the long-lost son of an English duke (the Duke of Bridgewater). The older one, about seventy, then trumps this outrageous claim by alleging that he himself is the Lost Dauphin, the son of Louis XVI and rightful King of France. The "duke" and "king" soon become permanent passengers on Jim and Huck's raft, committing a series of confidence schemes upon unsuspecting locals all along their journey. To divert suspicions from the public away from Jim, they pose him as recaptured slave runaway, but later paint him up entirely blue and call him the "Sick Arab" so that he can move about the raft without bindings.
On one occasion, the swindlers advertise a three-night engagement of a play called "The Royal Nonesuch". The play turns out to be only a couple of minutes' worth of an absurd, bawdy sham. On the afternoon of the first performance, a drunk called Boggs is shot dead by a gentleman named Colonel Sherburn; a lynch mob forms to retaliate against Sherburn; and Sherburn, surrounded at his home, disperses the mob by making a defiant speech describing how true lynching should be done. By the third night of "The Royal Nonesuch", the townspeople prepare for their revenge on the duke and king for their money-making scam, but the two cleverly skip town together with Huck and Jim just before the performance begins.
In the next town, the two swindlers then impersonate brothers of Peter Wilks, a recently deceased man of property. To match accounts of Wilks's brothers, the king attempts an English accent and the duke pretends to be a deaf-mute, while starting to collect Wilks's inheritance. Huck decides that Wilks's three orphaned nieces, who treat Huck with kindness, do not deserve to be cheated thus and so he tries to retrieve for them the stolen inheritance. In a desperate moment, Huck is forced to hide the money in Wilks's coffin, which is abruptly buried the next morning. The arrival of two new men who seem to be the real brothers throws everything into confusion, so that the townspeople decide to dig up the coffin in order to determine which are the true brothers, but, with everyone else distracted, Huck leaves for the raft, hoping to never see the duke and king again. Suddenly, though, the two villains return, to Huck's despair. When Huck is finally able to get away a second time, he finds to his horror that the swindlers have sold Jim away to a family that intends to return him to his proper owner for the reward. Defying his conscience and accepting the negative religious consequences he expects for his actions—"All right, then, I'll go to hell!"—Huck resolves to free Jim once and for all.
On the Phelps' farm
Huck learns that Jim is being held at the plantation of Silas and Sally Phelps. The family's nephew, Tom, is expected for a visit at the same time as Huck's arrival, so Huck is mistaken for Tom and welcomed into their home. He plays along, hoping to find Jim's location and free him; in a surprising plot twist, it is revealed that the expected nephew is in fact Tom Sawyer. When Huck intercepts the real Tom Sawyer on the road and tells him everything, Tom decides to join Huck's scheme, pretending to be his own younger half-brother, Sid, while Huck continues pretending to be Tom. In the meantime, Jim has told the family about the two grifters and the new plan for "The Royal Nonesuch", and so the townspeople capture the duke and king, who are then tarred and feathered and ridden out of town on a rail.
Rather than simply sneaking Jim out of the shed where he is being held, Tom develops an elaborate plan to free him, involving secret messages, a hidden tunnel, a rope ladder sent in Jim's food, and other elements from adventure books he has read, including an anonymous note to the Phelps warning them of the whole scheme. During the actual escape and resulting pursuit, Tom is shot in the leg, while Jim remains by his side, risking recapture rather than completing his escape alone. Although a local doctor admires Jim's decency, he has Jim arrested in his sleep and returned to the Phelps. After this, events quickly resolve themselves. Tom's Aunt Polly arrives and reveals Huck and Tom's true identities to the Phelps family. Jim is revealed to be a free man: Miss Watson died two months earlier and freed Jim in her will, but Tom (who already knew this) chose not to reveal this information to Huck so that he could come up with an artful rescue plan for Jim. Jim tells Huck that Huck's father (Pap Finn) has been dead for some time (he was the dead man they found earlier in the floating house), and so Huck may now return safely to St. Petersburg. Huck declares that he is quite glad to be done writing his story, and despite Sally's plans to adopt and civilize him, he intends to flee west to Indian Territory.