The novel opens with a prelude set roughly 14 years before the main events. David Pilcher, the creator of the Wayward Pines project, awakens from 1,800 years of suspended animation in the year 3813 AD. He and a small team, including his protégée Pam and his enforcer Arnold Pope, exit their underground superstructure, a vast mountain complex stocked with supplies, to explore the world outside. Where the town of Wayward Pines once stood in the Idaho mountains, they find only snow-covered forest and eroded cemetery stones. Pale humanoid creatures pursue them back to the portal. Two years later, Pilcher oversees the construction of a new town in the valley. He envisions it as a paradise where residents will know they are the last of humanity, protected from monsters by the electrified fence, and will find incomprehensible worth in their lives.
The main timeline begins two hours after Sheriff Ethan Burke, a former Secret Service agent, has told the town's 461 residents the truth: It is the distant future, the world outside belongs to monstrous creatures called aberrations, or abbies, and they are humanity's last survivors. In retaliation, Pilcher has killed all power to the valley, shut down the electrified fence, and locked the main gate open. Kate Hewson Ballinger, Ethan's former Secret Service partner and onetime lover, proposes evacuating everyone to the Wanderers' cavern, a hidden, defensible cave halfway up the surrounding cliffs, accessible through underground tunnels that Kate's secret resistance group had used as a meeting place. Ethan sends his wife, Theresa, and their 12-year-old son, Ben, with Kate's group. Kate and her husband, Harold Ballinger, part ways to lead separate groups.
The invasion is swift and brutal. Abbies pour through the open gate and kill residents who did not reach the tunnels. In the tunnels, Harold's group is overtaken, and Harold is killed in the darkness. Ethan and Hecter Gaither, the town's pianist and a volunteer fighter, fend off pursuing abbies as the group emerges and climbs the cliff face via steel cables. Only about 96 people reach the cavern, roughly one-fifth of the population. Kate bolts the heavy door as abbies hurl themselves against it, but the attack abruptly stops.
Meanwhile, Pilcher watches the carnage on surveillance monitors, rationalizing the massacre as divine punishment and planning to start over with people still in suspended animation. He summons Ted Upshaw, his loyal head of surveillance, and demands Ted identify who helped Ethan. In truth, Ted himself found footage of Pilcher and Pam murdering Pilcher's daughter, Alyssa, and passed it to Ethan. Pilcher later kills Ted to conceal the evidence.
A parallel storyline follows Adam Hassler, Ethan's former supervisor in the Secret Service, now a nomad sent by Pilcher on long-range reconnaissance beyond the fence. Hassler has survived alone in the wilderness for over 1,300 days, documenting a ruined world: abby swarms tens of thousands strong, the skeletal remains of Portland, the submerged Golden Gate Bridge. His sole motivation for volunteering to enter suspended animation was his obsessive love for Theresa Burke. Flashbacks reveal that Hassler deliberately sent Ethan to Wayward Pines knowing Pilcher would abduct him, so that Hassler could pursue Theresa. After arriving in the future, Hassler and Theresa lived together for over a year before Pilcher sent Hassler beyond the fence on what was intended to be a one-way mission. Now nearing the valley, Hassler finds the fence powerless and races toward the gate.
The next morning, Ethan leads a small team down from the cavern to infiltrate the superstructure. At the school, they find 83 survivors sheltering in the basement. Ethan and Hecter press on to retrieve car keys, but abbies swarm the house. Hecter is mortally wounded holding a staircase so Ethan can escape. Ethan mercifully shoots him, then flees in a Jeep.
While Ethan races toward the superstructure, the abbies return to the cliff. Theresa and Ben escape the cavern along a narrow ledge and spend hours down-climbing the rock face. They reach town and lock themselves inside the jail cell at the sheriff's station as abbies crash through the entrance. That night, Pam appears. She had been stranded outside the fence after Ethan previously cut out her microchip and has reentered the valley through the powerless, open gate, bent on killing Ethan. She points a shotgun at Theresa and Ben. Before she can fire, Hassler, who has been searching for Theresa, shoots Pam dead. He shares the bleak conclusion of his years of exploration: There is no other human civilization anywhere in the world.
Ethan crashes the Jeep into the superstructure tunnel and persuades Alan Spear, Pilcher's head of security and a friend of Alyssa's, to view the memory shard, a portable recording device containing footage of Alyssa's murder. The footage shatters Alan's loyalty, and he mobilizes his team to restore the fence and prepare a rescue. Ethan finds Pilcher drunk in his office, philosophizing about power. When Pilcher lunges with a knife, Ethan knocks him unconscious and ties him up, believing Pilcher's fate should be decided by the people of Wayward Pines. Ethan then addresses Pilcher's roughly 150 mountain personnel, playing the murder footage on a large monitor and destroying whatever loyalty remained.
At dawn, Ethan leads an armored convoy into town. They rescue the school survivors, retrieve Theresa and Ben from the jail cell, and transport everyone into the superstructure. The fence is restored. Out of 461 residents, only 108 survive. The community gathers to bury the dead.
Theresa confesses to Ethan that she lived with Hassler and loved him, believing Ethan was dead. Ethan is devastated, but Theresa points out his own past infidelity with Kate. She ultimately chooses Ethan. Ethan confronts Hassler, who does not deny engineering Ethan's disappearance. They reach a bitter truce: Hassler will walk away if Ethan never tells Theresa the truth. That night, Hassler climbs a sheer cliff intending to jump but finds Kate already there, also contemplating suicide, devastated by Harold's death. They share their pain and choose to go on living.
Francis Leven, the superstructure's steward, reveals that food rations will run out in roughly four years. The growing season is too short, and the invasion destroyed the livestock. Pilcher had known for years but refused to address the crisis. The people vote on Pilcher's fate. In a torchlit procession, every surviving human walks Pilcher to the gate. He is pushed through with a small pack of supplies. Within minutes, abby screams close in.
Before leaving Wayward Pines, Ethan releases Margaret, an intelligent female abby Pilcher had studied, into the wild. He tells Ben he hopes this act of kindness might carry meaning across the arc of evolution. That evening, Ethan tells the remaining 250 people their food is running out and they cannot stay. Rather than impose his decision as Pilcher did, he puts the plan of leaving the valley to a democratic vote.
One month later, the entire population walks out of their homes for the last time and converges on the superstructure. Ethan walks briefly with Kate and Hassler, who are now together. Ethan records a final message about humanity's enduring need to explore and their fragile hope for the future. In the suspension hub, residents climb into their chambers. Ethan tucks Ben in, then Theresa, and enters his own unit. As gas fills the chamber, his recorded words express hope that the future might yet belong to humanity. A single-line epilogue follows: 70,000 years later, Ethan Burke's eyes open.