Richard Forthrast, known as Dodge, is the black sheep of a large Iowa farming family. A Vietnam-era draft dodger who fled to British Columbia in 1972, he worked as a wilderness guide before smuggling marijuana across the border. He later went legitimate, cofounding a cat-skiing resort (where guests are ferried uphill by diesel-powered snow tractors rather than chairlifts) called Schloss Hundschüttler with his biker friend Chet, then partnering with Chinese game entrepreneur Nolan Xu to create Corporation 9592, the company behind T'Rain: an online multiplayer game designed to accommodate gold farmers, players who earn real money by selling virtual currency.
At a Thanksgiving family reunion in Iowa, Richard reconnects with his adopted niece Zula, a twenty-something Eritrean-born woman now living in Seattle, and meets her guarded boyfriend Peter. Richard's family is marked by tragedy: His sister Patricia, Zula's first adoptive mother, was killed by lightning, after which Zula was raised by Richard's older brother John, a Vietnam veteran with bilateral below-the-knee amputations. Richard's younger brother Jacob (Jake) lives off the grid on a survivalist compound in northern Idaho.
The crisis begins four months later when Peter, revealed to be a gray-hat hacker (someone who exploits security vulnerabilities without authorization but without malicious intent), sells a stolen credit card database to Wallace, a Scottish accountant working for a Russian organized crime figure named Ivanov. The data passes through a thumb drive borrowed from Richard that is infected with REAMDE, a ransomware virus demanding payment in T'Rain gold pieces. The virus encrypts Ivanov's sensitive financial records stored on Wallace's laptop and backup drive. Zula breaks up with Peter over his illegal dealings, but the three end up together at Peter's Seattle loft, spending the night playing T'Rain to pay the ransom without success.
Ivanov, having embezzled from his criminal organization's pension fund, arrives at the loft with a security team led by Sokolov, a decorated former Spetsnaz (Russian special forces) soldier. Wallace is murdered. Ivanov forces Peter, Zula, and Csongor, a young Hungarian systems administrator who served as Ivanov's hacker, to trace the virus creator, known as the Troll. Zula's colleague Corvallis Kawasaki at Corporation 9592 traces the Troll's IP address to Xiamen in southeastern China, and Ivanov flies the group there aboard his chartered jet.
In Xiamen, the group sets up in an unfinished skyscraper. Zula, Csongor, and Sokolov visit Internet cafés to locate the Troll, aided by Qian Yuxia, a Hakka tea merchant serving as their guide. They identify the Troll as Marlon, a young Chinese hacker leading a gold-farming crew called the da G shou, operating from Apartment 405 in a rundown building. Unknown to any of them, Apartment 505 directly above houses a bomb factory run by Abdallah Jones, a Welsh-born Islamic terrorist responsible for 163 deaths, who has been under surveillance by Olivia Halifax-Lin, a British-Chinese MI6 agent working from an office across the street.
When Ivanov orders the assault, Zula deliberately misdirects the Russians to Apartment 505 to protect the hackers, warning Marlon's crew by flashing their power on and off. Sokolov's team breaches 505 and collides with Jones's jihadists in a catastrophic gun battle. Ivanov shoots Peter dead in the stairwell. Jones kills Ivanov in the cellar and handcuffs himself to Zula. The building catches fire and partially collapses. Marlon rescues the unconscious Csongor from the rubble. Sokolov escapes to Olivia's office building. Jones commandeers a taxi with Zula as hostage. Yuxia rams the taxi with a van, but Jones escapes onto a boat, taking both Zula and Yuxia captive.
The survivors scatter. Jones takes the women to a fishing vessel operated by his support network. Csongor and Marlon pursue in a small boat but cannot rescue them. Sokolov evades capture through Xiamen, discovers Olivia's spy identity, and tracks her to nearby Gulangyu Island, where they form an uneasy alliance.
Jones forces Zula to lure the jet's Russian pilots to a meeting, and his men coerce them into flying out of China. The pilots file a false flight plan, dive to vanish from radar, and shadow a 747 across the Pacific. During the flight, Jones's lieutenant Khalid attempts to rape Zula; she wounds him with DVD shards and kills him with a pistol. Jones spares Zula when she reveals that her uncle Richard has hundreds of millions of dollars and can help Jones cross the border into the United States.
Sokolov and Olivia escape to the Taiwanese island of Kinmen. Olivia is extracted to London, where she develops the theory that Jones flew to North America rather than the southern Philippines. Meanwhile, Yuxia helps Csongor and Marlon hijack the fishing vessel from Jones's men. When it runs out of fuel, the three improvise sails and drift for two weeks before reaching the Philippines, where Seamus Costello, a retired U.S. Army captain in counterterrorism, finds them by tracking the Troll's IP address.
Richard discovers Zula is missing and investigates. Working with Corvallis, he monitors T'Rain data and receives a smuggled note confirming Zula was alive days earlier. Olivia intercepts Richard before he can fly to China, convincing him that Zula is likely in North America.
Jones crash-lands the jet in a remote British Columbia valley. His group murders locals for vehicles, recruits jihadists from sleeper cells, and imprisons Zula in a plywood cell in a stolen RV. Jones studies Zula's geotagged photographs and Richard's online presence to plan a border crossing through old mining tunnels. Zula secretly obtains a spare padlock key and conceals it, waiting for her chance.
Jones arrives at the Schloss during its off-season, cuts all utilities, and forces Richard to guide the expedition through mine tunnels across the U.S. border toward Jake's compound on Prohibition Crick. A jihadist car bomb at another border crossing kills over a hundred people as a diversion. Olivia, in Vancouver, traces missing bear hunters to Jones's path. Sokolov, having jumped off a containership in Seattle, tracks down Igor, one of Ivanov's criminal operatives who stole Peter's rifle. Olivia extracts Sokolov from FBI surveillance, and they flee east across the Cascades.
Zula escapes her guards at night using her hidden key, aided by a cougar attack on raccoons she deliberately attracted with food scraps. She reaches the Schloss and sets fire to the tavern to trigger the sprinkler alarm. Chet rides up on his motorcycle, is shot by a pursuing jihadist, but drives Zula through the mine tunnels to the American side. Mortally wounded, Chet detonates a Claymore mine strapped to his chest as the jihadists approach.
The final battle converges on Jake's compound. A helicopter carrying Seamus and Yuxia is shot down. Sokolov and Olivia, guided by Jake, take up positions and engage the jihadists. Sokolov occupies Jake's cabin until an RPG destroys the upper story, trapping him with a crushed leg. Zula shoots the RPG operator. Csongor and Marlon, having flown to a military base and driven north, crash their SUV through jihadist reinforcements at Jake's gate. Yuxia kills Jahandar, one of Jones's snipers, with a shotgun. Jones flees on an ATV, which Sokolov disables. Richard, hobbling through the mining camp with a sprained ankle and a revolver, encounters Jones alone. After Jones throws a grenade that Richard tosses clear, Richard shoots Jones dead at point-blank range.
One year later, at the Thanksgiving reunion, the survivors reconnect. Zula sits with Csongor, now her partner. They Skype with Olivia in London, who is living with Sokolov; Sokolov lost his lower right leg and now wears one of the late John's donated prosthetic limbs. Seamus arrives with Yuxia, who is recovering from abdominal wounds. Marlon works for Nolan Xu's company in Beijing. The family gathers at the shooting range by the creek, carrying on its traditions while bearing the scars of what they endured.