This post contains lots of spoilers!!
Gray lives in Claysoot, a small somewhat primitive village surrounded by a Wall. Whenever anyone tries to go over the Wall, they are returned dead and burnt. All the males in the village are Heisted at the age of 18. Gray's brother Blaine is about to turn 18. He is Heisted and Gray feels empty. But he does get closer to Emma, a girl that he's been into since childhood. Love is an unusual concept in Claysoot. Boys are "slated" to different girls every month in an attempt to keep the population stable. When boys are taken away at 18, a long-term love is impossible. But they both wish it was possible for them.
Gray finds part of a letter that his mother wrote to Blaine before she died. It seems that she had kept a secret about Gray. Gray gets curious and finally finds out that him and Blaine are actually twins. Gray is also 18 but wasn't Heisted like his brother. His mother knew something was wrong in the town and thought that would be a good way to test the Heist. Gray decides to chance the Wall. He thinks that the fact that he's actually 18 will protect him. Emma follows.
What they find is a future dystopian America. The United States has been divided into AmEast and AmWest who are constantly at war. There are extreme water shortages. They are taken to Taem (the capital city) and Frank, the leader of AmEast. Frank explains that Claysoot was created by an evil man named Harvey. Harvey is a scientist and created Claysoot as an experiment that they are trying to stop. Harvey has taken refuge with Rebels and the Order (the AmEast military) are searching for them. Gray is reunited with his brother Blaine, who has joined the Order along with all of the boys who've been Heisted from Claysoot.
While wandering around, Emma and Gray see a man being shot by Order soldiers for stealing water. Gray is horrified and begins to get curious. They snoop around and find out that in addition to stopping Harvey, they are also trying to capture/kill Elijiah, who started the Rebels. He committed some minor offense and was going to be executed and instead, escaped to the forest. Gray decides that he was wrong to trust Frank and wants to find these Rebels. The Order finds out and then plans to execute Gray.
Gray is able to escape but runs across an Order camp in the forest where his brother is. The leader figures out that Gray is wanted and tries to kill him, but that's when the Rebels attack the camp. Blaine is shot, but Gray is able to escape with him. They wander around the forest for a few days until being taken captive by the Rebels. The Rebels take Blaine to the hospital. Gray is introduced to one of the captains, Owen, who happens to be his father.
The Rebels aren't sure whether or not to trust Gray, but eventually he is accepted. They are afraid he's a Forgery - a clone of a Heisted boy. They tell him the truth about Frank. Harvey was not the one who created Claysoot - Frank was. He also created 4 other similar villages in order to harvest soldiers. Each village had a varying degree of resources - A had the most and ended up destroying itself; B, C (Claysoot), and D (Saltwater) were relatively successful; and E which had very extreme conditions and everyone there ended up dying. He enlisted Harvey's help to create Forgeries of the boys so he would be able to have even more soldiers. Frank was only able to make one Forgery from a boy and he wanted Harvey's help to make unlimited Forgeries. Harvey complied until he had a change of heart and escaped to the Rebels.
Gray befriends Bree, a fiery girl from Saltwater (where girls were Heisted instead of boys). He is attracted to her, but remains faithful to Emma, who he had to leave behind when he escaped Taem. One day they find out that the Order is planning on using a disease to infect the Rebels. They must find the vaccine. Gray offers up a plan, which is accepted, that he should pretend to be Blaine (because Frank thinks Blaine is still loyal) and bring Harvey to Taem as his prisoner. There they will find the vaccine and escape back to the Rebels.
Bree goes with them because she knows the way. The plan is mostly successful. Harvey ends up being left behind, which he knew would be a possibility, and is executed. Gray is also able to free Emma, although he finds her in bed with another boy from Claysoot. He is angry but Emma is apologetic and claims that she thought he was dead. He is unsure whether he can forgive her but he brings her with them when they escape. Bree is shot in the escape. While camping in the forest on the way back to Rebels, Bree asks Gray to kiss her and he does (in front of Emma!!).
When they get back to the Rebels, the vaccine is distributed. Gray continues to ignore Emma, even though she clearly wants him to forgive her. Gray and Bree continue hooking up, but they don't have sex, because Bree doesn't want to get pregnant and Gray thinks that would make getting back with Emma impossible (because he's clearly still entertaining the idea of going back to Emma).
At the end, the captains decide to send a team to village A,the one that supposedly destroyed themselves. Harvey and Gray saw a video feed of the settlement while in the capital and it appears that there may be people still there. They decide to send people there to rescue them in the hopes that they'll join the Rebels. Gray, Owen, Emma, and Bree are among the team to go.