The novel opens in the (fictional) village of Essendean in the Ettrick Forest area of the Scottish Lowlands in 1751. The main character and narrator is 17-year-old David Balfour whose sole remaining parent, his father, has recently died. The minister of Essendean, Mr. Campbell, hands David a sealed letter left by his father with instructions that it be delivered to his father’s brother, Ebenezer, at his family's ancestral estate, the House of Shaws in Cramond. Mr. Campbell tells David that he believes the letter may well prove to be advantageous to him.
After two days' walk cross country, David arrives at the ominous House of Shaws. There he is confronted by the paranoid Ebenezer with a loaded blunderbuss. His uncle is miserly, living on "parritch" and small ale, and the House of Shaws itself is partially unfinished and somewhat ruinous. David is allowed to stay and soon discovers evidence that his father may have been older than his uncle, thus making David the rightful heir to the estate. Ebenezer asks David to get a chest from the top of a tower in the house but refuses to provide a lamp or candle. David is forced to scale the stairs in the dark and by sudden luck of lightning illuminating the night scene discovers that not only is the tower unfinished in some places, but the steps simply end abruptly and fall into an abyss. David concludes that his uncle intended for him to have an "accident", perhaps so as not to have to give over his nephew's inheritance.
David confronts his uncle, who promises to address the matter the next morning. A ship's cabin boy, Ransome, arrives the next morning and tells Ebenezer that Captain Hoseason of the brig Covenant needs to meet him to discuss business. Ebenezer takes David to a pier on the Firth of Forth, where Hoseason awaits, and David makes the mistake of leaving his uncle alone with the captain while he visits the shore with Ransome. Hoseason later offers to take them on board the brig for a drink and a brief tour, and David complies, only to see his uncle returning to shore alone in a skiff. David is then immediately struck senseless.
David awakens, bound hand and foot, in the hold of the ship, and learns that per arrangement with David's uncle, the captain plans to sell him into indentured servitude in the Carolinas. But the ship encounters contrary winds, which drive her back toward Scotland. Fog-bound near the Hebrides, they strike a small boat. All of the small boat's crew are killed except one man, Allan Breck Stewart, who is brought on board and offers Hoseason a large sum of money to drop him off on the mainland. David later overhears the crew plotting to kill Alan instead. David and Alan barricade themselves in the roundhouse, where Alan kills the murderous helmsman and David wounds Hoseason. Alan then demonstrates his superior fighting skills as he easily kills five more men and intimidates the remaining crew into backing down.