The novel is set in the small Irish village of Glennkill, where a flock of unusually perceptive sheep discover their shepherd, George Glenn, lying dead in the meadow with a spade driven through his body. Miss Maple, the cleverest sheep in the flock, calms the panicked animals and persuades them to investigate. She argues they owe George a debt, and the sheep unanimously bleat "Justice!" The flock's key members take lookout positions: Sir Ritchfield, the elderly lead ram; Mopple the Whale, the memory sheep who never forgets what he observes; Zora, a sure-footed Blackface ewe; and Othello, a black four-horned Hebridean ram who spent his youth in Dublin Zoo. Maple examines the body and discovers a sheep's hoof print on George's stomach, a detail she keeps secret from the flock.
The first humans to arrive include Tom O'Malley, a local who stumbles on the body while walking to the pub. A group follows from the village: Josh Baxter, the thin pub landlord; Ham (Abraham Rackham), the butcher; Gabriel, a small, admired local shepherd; and Lilly, a woman with a close personal connection to George, who weeps over him. Othello overhears Ham threatening Lilly and mentioning George's will. Police remove the corpse, and the sheep begin collecting questions. A lamb confesses that during the night he saw the spade already in the ground and a shaggy figure dancing nearby.
Life without a shepherd unsettles the flock. They consecrate a herb-rich patch of meadow as "George's Place," a memorial where no sheep may graze. Kate, George's red-haired wife, visits with Father William, the village priest whom the sheep call "God." Kate reveals George left a will with a lawyer. When God suggests selling the sheep to Ham, Kate refuses. A crowd of villagers invades the meadow, and the sheep overhear gossip about George's fortune and his unusual closeness to his sheep. Maple deduces that because the tide was high on the night George died, the murderer chose not to push the body off the cliffs: George was meant to be found.
Mopple carries a clue to Maple: Ritchfield saw one of the first humans to visit the body handle something near it, but sneezed and forgot which one. Ritchfield has been intimidating Mopple to keep quiet about this. Mopple later encounters Ham in the mist, and when the butcher chases him, Ham stumbles off the cliffs and is badly injured. Under a lime tree in the village, Mopple overhears frightened men: Ham has deposited evidence with a lawyer, and his death would expose a dangerous secret. Maple ventures to Kate's house and eavesdrops; when Lilly arrives to offer condolences, Kate slams the door. Privately, Maple tells Mopple about the hoof print and raises the possibility that a sheep was involved in George's death.
One night, Josh, Tom, and Harry the Sinner, a local villager, sneak to George's shepherd's caravan in stocking masks, searching for drugs to prevent scandal. They cannot open the security lock. Maude, the ewe with the flock's keenest nose, detects a concealed human observer lying flat atop the dolmen, a prehistoric stone monument near George's body, watching the intruders. A man in a quiet car also arrives, knocks on the caravan door with a coded pattern, and leaves when it will not open.
Most of the flock wants to abandon the investigation, but Maple rallies them by invoking the terrifying story of the wolf in sheep's clothing. Gabriel arrives as temporary shepherd with his own flock of strange, nearly fleeceless sheep. Othello recognizes Gabriel's tactics as those of an animal tamer. Rebecca, a confident woman in a red dress, arrives in Glennkill; the sheep detect George's family scent on her and realize she is his daughter. Through conversations between Rebecca and Beth, a devout woman who lives near the church, the sheep learn that George was poisoned first and already dead when the spade was driven through him. Beth links the spade to a superstition about pinning a corpse's soul and reveals that something fundamental changed in Glennkill seven years ago.
Othello infiltrates God's church at night and hides in the confessional. God mistakes him for an expected visitor and nervously urges the listener to leave Ham alone. When God discovers the black ram, he flees screaming. As Othello leaves, a fourth shadow follows: Melmoth, Ritchfield's long-lost twin brother, a legendary ram who disappeared years ago.
Melmoth tells the flock a crucial story. Years ago, George and Ham unearthed the body of Wesley McCarthy, a developer who had planned to build a slaughterhouse that would ruin the village. George deduced that a group of villagers had collectively murdered McCarthy and were fabricating alibis. He devised a plan: Ham would copy his shop's surveillance footage, which contradicted the alibis, and deposit copies with a lawyer, ensuring the village knew the evidence would be released if anything happened to either of them. This explains why no one dares harm the butcher and why the village has lived in fear ever since. Maple concludes that George separated himself from the village after discovering the murder, and that the spade through his body was meant to echo McCarthy's killing.
Maple identifies Gabriel as the concealed observer from the dolmen, based on his knowledge of the midnight intruders and his ability to disguise his scent. She deduces he is the villagers' leader. Zora communicates with a ram from Gabriel's flock who delivers a devastating warning: Gabriel's sheep are a meat breed being fattened for slaughter. Melmoth teaches the flock the "art of paying attention," training them to overcome fear and observe humans closely. The sheep then fake symptoms of scrapie, a fatal neurological disease, and Gabriel flees with his flock.
A lawyer reads George's will under the village lime tree. Kate receives his library, Rebecca his land, Beth his Bible, and Ham his pistol. George's remaining fortune is left to his sheep so they can travel to Europe as he promised them. Both Gabriel and Rebecca volunteer as shepherd; the sheep unanimously choose Rebecca.
Rebecca opens the caravan and, guided by the sheep, uncovers a buried box under the dolmen containing packets of drugs, a video cassette of the surveillance footage, and papers. She reads aloud from
Wuthering Heights: "The murdered do haunt their murderers, I believe" (267). The man who previously knocked on the caravan door returns, confirms his drug organization had nothing to do with George's death, and takes the drugs and evidence. The
Wuthering Heights passage triggers Maple's breakthrough: She theorizes that Beth poisoned George and drove the spade through his body to pin his ghost to the ground.
The sheep perform at the annual Smartest Sheep in Glennkill contest at the Mad Boar pub, reenacting the murder on stage. Beth enters the pub holding a dropped rag that bears her own initials and asks to speak. She reveals the truth the sheep never anticipated: George came to her house the Sunday before his death to say goodbye to life itself. George poisoned himself, and Beth drove the spade through his already-dead body at his insistence. George had moved toward "something black" over the seven years since discovering the village's secret, too afraid and too lonely to face Europe.
The sheep are bewildered. Fosco, a stout grey veteran ram, explains suicide: Humans sometimes look at the world and decide they do not want to live. Ham corners Mopple but does not harm him; instead, he admits he should have noticed how badly George was struggling, and lets Mopple go.
In the aftermath, Beth leaves Glennkill for an island. The man from the drug organization slips the McCarthy video cassette to Inspector Holmes, the investigator on George's case, offering him a solved cold case. Ham visits Rebecca, speaking of transmigration of souls, and shakes her hand peacefully. Melmoth gathers the sheep at the cliffs, then vanishes, climbing down to the beach and walking away along the shoreline. The sheep believe he has become a cloud-sheep; Othello alone understands that Melmoth chose solitary wandering once again. Rebecca announces they leave for Europe the next morning, and the sheep anticipate the journey George always promised them.