Instead of being given the cure for the deadly Flare disease as he'd been promised after surviving the Scorch, Thomas is separated from his friends and kept in isolation for three weeks. Alone with his thoughts and his anger, Thomas is surprised that only the fact that WICKED (World in Catastrophe: Killzone Experiment Department) won't let him bathe is what's driving him crazy.
Finally, "Rat Man" enters the cell and explains everything to him. Rat Man, so nicknamed by Thomas because of his rodent-like features, had been the man to inform Thomas and the other Gladers about the Scorch. Now, he hopes to convince Thomas to continue to work with WICKED to find a cure for the Flare. The disease eats away the minds of the afflicted until they turn into Cranks, zombie-like creatures that roam cities killing people until they're killed themselves.
Fortunately for Thomas, he and most of his friends are Munies — immune to the Flare. That's why they've been put through the Maze and the Scorch trials. The disease works by eating away areas of the brain. It's hoped that by monitoring the Munies in various stress and decision-making scenarios, scientists can map out a blueprint of their minds and figure out a way to cure those infected.
Thomas is released from isolation and reunited with his friends — Minho, Newt, Frypan and others from the Maze and the Scorch. When he meets up with Teresa again, he can't help the feelings of distrust that creep into his mind. His closest friend had done nothing but hurt and betray him throughout the Scorch. Her constant assurance that she was only doing what the old Thomas would have wanted her to do, does nothing to help his emotions.
All of his memories had been wiped away before he entered the Maze, as they were for all the Gladers. The few memories that have managed to re-emerge do not support Teresa's claims that WICKED is good. Rat Man interrupts their reunion to inform them that they will now be given all their memories back. Of course, the procedure requires them to allow WICKED to put a probe into their brains to remove the device.
Rat Man also tells them the names of those who aren't immune from the Flare. Thomas is saddened to hear Newt's name among those infected. Sometime later, Newt gives Thomas a note and tells him not to read it yet. He will know the right time.
Thomas, Minho and Newt refuse to undergo the operation, but Rat Man eventually tries to force them. Thomas is dragged into the operating room and sees Brenda, a girl he formed an attachment to in the Scorch. Brenda helps him and the others escape. They scour the WICKED compound for their friends, but Teresa and the others have escaped without them.
Thomas again feels the sting of betrayal. Brenda leads Thomas, Minho and Newt to Jorge — another friend from the Scorch. After a battle with armed guards, Jorge manages to fly them out of the area in a Berg, which is an airship. Brenda warns them that until they get the devices out of their brains, WICKED can still, if they get close enough, manipulate them. She tells them of a man named Hans who can remove the devices. The group decides to fly to Denver to find him. Denver is one of the few cities left that has not been overrun by the Flare. Uninfected people can still lead fairly normal lives, but everyone is monitored closely to keep an outbreak from occurring.
When they arrive, Newt insists on staying aboard the Berg while the others hunt for Hans. Thomas and Minho have never seen so many people in one area. A stranger approaches Thomas and his friends. He informs them that they are suspected of having escaped from WICKED and that they should follow his advice.
He gives Thomas a note. It's an address and is signed by Gally. Gally and Thomas were enemies in the Maze, and it was Gally, who under the control of WICKED, killed Thomas' best friend, Chuck. Thomas thought he had beaten Gally to death, but Brenda assures him he didn't. She doesn't believe the note could be from Gally, however, because the boy went crazy with guilt when he realized what WICKED had manipulated him to do.
Gally's note says that he's now a member of the Right Arm. Brenda and Jorge explain it's a renegade group intent on bringing down WICKED. Against everyone else's advice, Thomas insists they find Gally before finding Hans.
Gally tells them that people from the Right Arm contacted him while he was recovering from the Maze. They said he could get out of the WICKED compound if he pretended to be crazy, so he did. The Right Arm then took him into protective custody.
Gally informs Thomas' group that Denver is rife with infected people, but they are government officials and can mask the effects with an expensive drug called Bliss. Also, Munies are disappearing. The Right Arm suspects they are being kidnapped by WICKED so they can start a whole new set of trials to try to find the cure. The Right Arm wants Thomas and his friends to help them fight WICKED. They agree, but it will have to wait until they find Hans.
The following day they meet with Hans, but when the old man prepares to take the device out of Thomas' brain, WICKED takes control, throwing Thomas' body into convulsions. Thomas is forced to pick up a knife and threaten his friends. After an intense fight, the others are able to sedate him, and the implant is removed. Later, as Thomas and his friends get something to eat in a coffee shop, an infected man is arrested. Brenda and the others manage to escape before the authorities arrive, but Thomas is caught. When it's discovered he's a Munie, they decide to sell him to the people collecting Munies.
Thomas is rescued when a motorized and armed cop vehicle opens fire on his captor. A voice from within the car tells him to get in. Thomas is shocked to see an image of Rat Man on a screen in the car. He informs Thomas that he [Thomas] is the last hope for humankind. WICKED desperately needs him to return to the main compound to finish creating the protocol that may cure the Flare. Rat Man also tells him that Newt is succumbing to the disease at an alarming rate and will be insane very soon. Rat Man lets Thomas go, hoping he'll return to WICKED on his own accord.
When Thomas and the others return to the Berg, they discover that Newt is missing. A note informs them that he's been taken to live with the other Cranks in the city. Minho insists they have to rescue their friend before they join the Right Arm. Brenda explains that Newt has probably been taken to the Crank Palace. It's an isolated town where the newly infected are sent to live while they are still rational.
Thomas and his friends find the Crank Palace and bribe the guards to take them to Newt. They find their friend living in a dilapidated bowling alley. Newt refuses to leave with them, eventually pulling a weapon on them and threatening to use it if they don't leave. He knows he's a lost cause. The Flare is ravaging his brain, and he has little control over his actions.
As they solemnly make their way back to the Berg without him, guards run up behind them and warn them to flee. The Cranks have gone insane and are launching a revolt. Thomas and his friends reach the Berg and return to Denver. Thomas remembers the sealed letter Newt had given him back at WICKED. He reads it. The note begs Thomas to kill him when he knows the Flare has consumed his mind. Thomas regrets that he failed his friend's last request.
When they arrive back in the city, armed guards greet them. Thomas and his companions are taken to a holding area where they meet up with many of their old friends, including Teresa. She tries to convince Thomas that she and the other group from WICKED were told that he'd escaped with Minho and Newt. She'd tried to find him but couldn't.
Teresa tells Thomas that WICKED has been rounding up all the Munies they can find to start another series of trials. Thomas still doesn't trust her, but they agree to work together to escape. They overpower guards sent to bring them food.
One guard explains that they're not working for WICKED but for the Right Arm. Thomas and Brenda force him to take them to the resistance headquarters. They have to fight through an army of Cranks to get there, but they finally meet with Vince, the leader. He explains that he wants the Munies to help them break into and take down WICKED. Thomas and Brenda agree to help. Thomas will be dropped off first and will place a device that can disable WICKED's weapons.
On his way to the Berg that will take him to WICKED, Thomas' van again runs into Cranks. Thomas recognizes Newt. He insists on talking to his friend. Newt isn't happy to see Thomas. He begs Thomas to kill him. Finally, out of horror and pity, Thomas shoots him. He refuses to tell any of his friends about the incident.
Thomas is dropped off in a forest just outside of WICKED headquarters. Rat Man welcomes him back. Thomas pretends to have to use the restroom so he can plant the weapon-disabling device. He is then introduced to a surgeon and a psychiatrist.
WICKED feels the only way to get the last information they need to create a cure is to dissect Thomas' brain while he's still alive. The procedure, of course, will kill him, but his sacrifice will save the human race. His agreement is no longer an option. They will do the operation whether he wants it or not.
They give him a few minutes alone to write notes to be delivered to his friends. Thomas hopes the Right Arm will arrive in time, but they don't. He is forced into an operating room as the first wave of the resistance force arrives. He is drugged and passes out.
When Thomas wakes, he finds he's alone. A letter from Chancellor Paige, the leader of WICKED, explains that she feels Thomas and the other Munies have suffered enough and have done all they can. She says that she saved him from surgery because WICKED has enough patterns and can figure out a cure from them. She leaves him a map that shows the location of other captive Munies and a secret exit. The exit is a Flat Trans, which will transport them to safety.
Thomas learns that the Right Arm plans to blow up the WICKED building without getting the captive Munies out. He finds his friends, and Gally joins them. They head back into the Maze, where the Munies are being kept.
Thomas is shocked to find that the Munies vary in age from children to adults. Thomas organizes them, but the Right Arm begins to detonate their explosives. The building begins to disintegrate around them. WICKED sends Grievers — half-machine, half-animal creatures — to stop them, but Thomas and Teresa destroy them. About 200 Munies survive and make it to the Flat Trans, but they're still not safe. As many leave through the Flat Trans, Rat Man and several WICKED soldiers arrive to stop them. Thomas and his friends fight them as other Munies continue to transport to safety.
In a rage, Thomas beats Rat Man to the ground and strangles him. His friends kill the guards as well. As they run toward the Flat Trans, more explosions rock the building. A piece of the ceiling plummets toward Thomas, but Teresa pushes him out of the way. The rubble crushes her, and she dies. Minho and Brenda drag Thomas through the Flat Trans toward safety. Then Brenda destroys the Flat Trans so no one can follow them. Thomas marvels at the natural beauty of their new home. He and Brenda contemplate their new life as the sun sets.
In a memorandum to her associates, Chancellor Paige explains how WICKED always acted for good, but she realized that their plans had not always been the best. She explains that though WICKED's initial plan to find a cure has failed, they still succeeded in saving humankind by sending the immune to a place of safety where they can live while the rest of humankind destroys itself.