Sherlock Holmes (Benedict Cumberbatch) and John Watson (Martin Freeman) receive a visit from Henry Knight (Russell Tovey), who witnessed his father's death by a "gigantic hound" at Dartmoor 20 years earlier. After years of therapy, Henry has visited the hollow where the killing occurred, only to have his terrors return, prompting his request for help. Although initially dismissive, Sherlock suddenly becomes interested after being struck by Knight's use of "hound" instead of "dog". Sherlock and John arrive in Dartmoor to find that the hound is a local legend. They visit Baskerville, a nearby Ministry of Defence research base, using Sherlock's brother Mycroft's (Mark Gatiss) security pass. After Mycroft's credentials cause a security alert, a Doctor Robert Frankland (Clive Mantle) vouches for Sherlock's identity, despite knowing who he really is. Frankland intimates that he was a friend of Henry's father and is concerned for Henry's well-being.
That night, Henry tells John and Sherlock about the words "Liberty" and "In" in his dreams. Sherlock, John, and Henry then visit the hollow in the hope of confronting the hound. On the way, John notices what seems to be Morse code signals in the background (these were unrelated; they were headlight flashes from a group of doggers). When Sherlock and Henry arrive at the hollow, they both feel a sense of abject terror, and the trio leaves. At a local inn, Sherlock is visibly shaken and confesses to John that he saw the hound. A sceptical John tries to calm him, suggesting that he is imagining things. Sherlock reacts with anger, denying there is anything wrong with him. John tries to interview Henry's therapist, Louise Mortimer (Sasha Behar). However, during the interview, they are interrupted by Frankland, who blows his cover. Meanwhile, Henry appears to hallucinate about the hound in his home.
The next morning Sherlock realises that "hound" may be an acronym rather than a word. The pair run into DI Lestrade (Rupert Graves) who was sent by Mycroft to keep an eye on Sherlock. They interrogate the innkeepers about a past order for meat that John has spotted, which struck him as odd for a vegetarian restaurant. The proprietors own up to keeping a dog on the moor to boost the tourist trade, but assure the investigators that they had put it down because it was uncontrollable. This explanation satisfies Lestrade but not Sherlock, who insists that the dog he saw was monstrous.
After calling Mycroft, Sherlock gains access to Baskerville again. While searching the lower levels of the genetics labs, John finds himself trapped and then hears growling which he immediately assumes is the hound. Locking himself in one of the empty cages, he calls Sherlock, who eventually rescues him. Sherlock deduces that a chemical weapon designed to trigger violent hallucinations was responsible. Retreating into his "mind palace", a memory technique, Sherlock realises that "Liberty" and "In" stands for Liberty, Indiana. After viewing confidential files, he sees that "H.O.U.N.D." was a secret C.I.A. project in Liberty aimed at creating a hallucinatory anti-personnel weapon, but the project was abandoned several years before. Sherlock realises that Frankland, who participated in the project, has continued to experiment with the drug in secret.
After John receives a call from Mortimer that a rampaging Henry has run away with a pistol, John, Sherlock and Lestrade run to the hollow to find Henry about to commit suicide. Sherlock manages to talk him out of it, explaining that the hound was an hallucination; his father was actually killed by Frankland, who was wearing a gas mask and a sweater with "H.O.U.N.D. Liberty, In" on it. After the murder, Frankland silenced Henry with the weapon: the hallucinogen, which metabolised quickly and therefore was not detected, made him appear insane and doubt his own memories, so that his story would be doubted by the authorities. The chemical agent also produced the fog they encountered at the hollow; it was triggered by pressure pads in the area. As Henry calms down, they all see what they perceive is the hound (in actuality the dog the innkeepers could not bring themselves to kill after all, which the gas makes appear as a demonic monster). As they shoot the dog, Sherlock finds Frankland and catches him. Frankland admits he murdered Henry's father, because he had found him in the middle of an experiment. He also reveals that Henry's father actually died by hitting his head on a rock whilst being attacked by Frankland. Frankland attempts to flee but runs into the base's minefield and is blown up.
As Sherlock and John prepare to return to London the next morning, John wonders why he saw the hound in the lab despite not having inhaled the gas from the hollow, but later realises that Sherlock locked him in the labs in order to test his theory of the chemical agent.
In the closing scenes, Mycroft oversees the release of Jim Moriarty (Andrew Scott) from a holding cell in which he has written Sherlock's name all over the walls.