The central character and narrator is 17-year-old David Balfour. (Balfour is Stevenson's mother's maiden name.) His parents have recently died, and he is out to make his way in the world. He is given a letter by the minister of Essendean, Mr. Campbell, to be delivered to the House of Shaws in Cramond, where David's uncle, Ebenezer Balfour, lives.
David arrives at the ominous House of Shaws and is confronted by his paranoid Uncle Ebenezer, who is armed with a blunderbuss. His uncle is also 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 realises 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" so as not to have to give over his nephew's inheritance.
David confronts his uncle, who promises to tell David the whole story of his father the next morning. A ship's cabin boy, Ransome, arrives the next day 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 briefly, 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 the captain plans to sell him into slavery 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, Alan 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 and take all his money. David and Alan barricade themselves in the round house, where Alan kills the murderous Shuan, and David wounds Hoseason. Five of the crew members are killed outright, and the rest refuse to continue fighting.
The book begins precisely where Kidnapped ends, at 2 pm on 25 August 1751, outside the British Linen Company in Edinburgh, Scotland.
The first part of the book recounts the attempts of the hero, David Balfour, to gain justice for James Stewart (James of the Glens), who has been arrested and charged with complicity in the Appin Murder. David makes a statement to a lawyer and goes on to meet William Grant of Prestongrange, the Lord Advocate of Scotland, to press the case for James' innocence. However, his attempts fail, as after being reunited with Alan Breck he is once again kidnapped, and confined on the Bass Rock, an island in the Firth of Forth, until the trial is over, and James is condemned to death. David also meets and falls in love with Catriona MacGregor Drummond, the daughter of James MacGregor Drummond, known as James More (who was Rob Roy's eldest son), also held in prison, whose escape she engineers. David also receives some education in the manners and morals of polite society from Barbara Grant, Prestongrange's daughter.