Thomas has been in solitary confinement after rescue from the Scorch Trials. After several weeks, Rat Man comes in and tells Thomas that the Trials are over now, and that WICKED has all the information they need. He takes Thomas to an auditorium, where the remaining subjects of the Trials are gathered. Rat Man, who is really Assistant Director Janson of WICKED, says that they are going to give the subjects their memories back. Janson also tells them that the majority of the Trial subjects are Immune to the Flare, but that a few are not. Included amongst the control variables–i.e. those who are not immune–is Newt.
Thomas, Minho, and Newt refuse to undergo the memory procedure and are led to another room for solitary confinement. WICKED intends to force the procedure upon them, but Brenda, who is Thomas’s surgery technician, helps them escape. Brenda and Jorge have also been working for WICKED the whole time, but they hate the organization. They are now actually Thomas’s friends, and not just acting the part on behalf of WICKED. Brenda takes Thomas, Minho, and Newt to go find Jorge. Jorge is a pilot, and can fly a Berg out to escape the facilities. The friends manage to escape, but not without encountering WICKED guards. WICKED has a weapon called a Launcher, which electrocutes its victims. Thomas and Brenda are shot with Launchers, but they do manage to escape on the Berg. Thomas is upset to find out that Teresa and the other subjects have also escaped on a Berg: he believes that they left Thomas, Minho, and Newt behind.
Jorge navigates the Berg to the city of Denver in Colorado. Denver is supposedly a safe city that guards itself against the Flare infection very well. There is also a defected WICKED doctor there, a man named Hans. Brenda believes that Hans can help them remove the chips planted in Thomas, Minho, and Newt’s brains, so that WICKED can no longer control them. When they reach the Denver airport, Newt stays behind because he is not an Immune. At the airport, a man delivers a cryptic note to Thomas. The note is from Gally, who is still alive, much to Thomas’s surprise. Gally is now working for the Right Arm, an organization opposed to WICKED. Before visiting Hans, Thomas and his friends visit Gally. Gally informs them of two key facts. First, Denver has been corrupt for a very long time and is actually heavily infested with the Flare. Second, someone has been kidnapping Immunes.
After seeing Gally, Thomas and his friends visit Hans, who manages to remove their WICKED control chips. As they are waiting in a coffee shop after seeing Hans, Flare testers attack a drugged-out infected man. They also capture Thomas, who lingered for too long. Thomas’s captors are bounty hunters, who want to sell him due to his Immune status. WICKED weaponry guns down Thomas’s captors, and Janson appears on a screen, asking Thomas to come back to WICKED. He says Thomas is the ‘Final Candidate’. WICKED is not coming down to Denver because of the crazy infection rates. Thomas’s friends find him again after this encounter with Janson. They head back to the Berg, only to find that Newt is gone: he has been taken by other Cranks and is now living with them. Newt’s deterioration due to the Flare is exponential. Thomas and his friends hunt down Newt, who is living at the ‘Crank Palace’, the place where all the infected people are quarantined. Newt, who is already partially insane, tells them to leave him alone. Broken and upset, Thomas and his friends are chased out of the quarantine by other Cranks, just barely making it on board their Berg in time. Jorge flies the Berg back to the Denver entry point, but Flare tester bounty hunters immediately capture them.
When Thomas and his friends are taken captive, they find that Teresa, Aris, and other members of their original groups are also prisoners of the bounty hunters. Minho helps overpower guards who come in to give them food. The guards are working for the Right Arm, not for WICKED. Thomas and Brenda insist on talking to the higher-ups of the Right Arm, and are taken through the city to the Right Arm headquarters. There, they meet Gally and the Right Arm’s head, Vince. Vince says that they are running a lookalike operation: they will pretend to sell immunes to WICKED and then infiltrate the complex. Thomas agrees to be part of this plan. He will pretend to go back as the ‘Final Candidate’, and will plant a device that will disable WICKED weapons.
As they drive back through the city to the Berg that will take Thomas to WICKED, Thomas and the Right Arm personnel encounter Cranks on the street. Thomas sees Newt and tries to save him, but Newt begs for Thomas to kill him instead. Thomas finally respects his friend’s wishes, killing him.
Thomas is flown up to WICKED, and pretends to hike back into the facility. Rat Man tells Thomas that they need him to sacrifice himself for science: the doctors need to read his brain and use for the cure. Thomas asks for more time, hoping the Right Arm will get here before the fatal surgery. Janson does not give Thomas much time or choice, and is putting him under anesthesia just as the Right Arm does arrive. Thomas goes unconscious from an injection, but wakes up to find a letter from Chancellor Ava Paige, who has a backup plan: she asks Thomas to find all the Immunes, who are hidden in the Maze, and take a Flat Trans to a safe place. As Thomas runs out to look for his friends, he realizes that the Right Arm intends only to destroy WICKED. Explosives are going off everywhere. When Thomas finds his friends, he takes them to the Maze to help get the Immunes out and to the Flat Trans. In the process, they have to fight Grievers deployed to kill them. Many people die from explosions and falling debris.
Just before Thomas and his friends enter the Flat Trans, Janson and backups arrive to stop them. Thomas and his friends fight them, and Thomas kills Janson. As they prepare to finally enter the Flat Trans, Teresa dives and saves Thomas from a falling piece of ceiling; the ceiling crushes Teresa instead, killing her. Thomas and his friends enter the Flat Trans, arriving in a lush nature hideaway. Brenda disables the Flat Trans and burns the entrance around it. The group prepares to begin life again. A final correspondence from Chancellor Ava Paige reveals that the Chancellor planned this backup plan because she was afraid that a cure would never be found. She thinks that Immunes were the real hope for humanity all along. Her email also reveals that the Flare was actually released as a form of population control by the government.