After surviving the night trapped in the Maze, Thomas and Minho explore Sector 7 and discover the body of the squashed Griever. Inside, they extract a beeping electronic cylinder labelled with the number 7 and 'W.C.K.D.'. Teresa soon awakens, recognizing Thomas and revealing two syringes of blue anti-venom, which successfully cure Alby of his Griever sting.
The status quo disintegrates: the Glade gates fail to shut at sunset, allowing a swarm of Grievers to massacre dozens of Gladers, including Alby. Blaming Thomas, Gally stages a coup, preparing to banish Thomas and Teresa. In an act of radical desperation, Thomas intentionally stings himself with a severed Griever stinger to unlock his memories. He discovers that he and Teresa were researchers working for W.C.K.D. who helped design the Maze trial before rebelling and being sent in themselves.
Thomas, Minho, Newt, Teresa, Chuck, and a band of loyal Gladers fight their way through the Maze into the Griever exit hatch ('The Griever Hole'), entering the electronic code sequence. They emerge into a sterile, high-tech bunker littered with the corpses of armed scientists. A video message from Chancellor Ava Paige plays: she explains that massive solar flares scorched Earth, followed by the catastrophic airborne pandemic called 'The Flare'. The teenagers are biologically immune; the Maze was designed to monitor their brain activity during high-stress survival scenarios in order to synthesize an antiviral cure. At the conclusion of the video, Paige appears to commit suicide via a gunshot to the head as armed troops breach the lab.
A delirious, stung Gally suddenly appears with a handgun, having followed their path. Minho impales Gally through the chest with a spear, but Gally discharges his gun—fatally wounding Chuck, who dies in Thomas's arms after passing him his carved wooden totem. Armed, masked tactical commandos storm the facility, rushing the survivors onto a transport helicopter.
As the helicopter ascends, the Gladers look down to see their Maze sitting in the middle of a vast, desolate desert wasteland. In a final reveal, Chancellor Ava Paige wipes fake blood from her temple in the pristine boardroom, declaring that the subjects have surpassed expectations and that 'Phase Two' is now underway.