In the distant future, the Starship UK soars through interstellar space. Its citizens live in the vast city that it contains. In a classroom, each of the children is called up and given their grades by a Smiler, a mannequin sitting in a booth. All of the students but one get good marks, including Mandy Tanner. The failing student is Timmy. When he goes to get his marks, the Smiler winds around and reveals a frowning face.
Afterward, Timmy prepares to catch the elevator to the London section, 20 decks away. Mandy refuses to ride with him, warning him that he'll be sent below because of his grades. Timmy tries to go after him, but a robed figure blocks his path. Timmy waits until everyone goes and then catches the next elevator. The image of a young girl appears on the mounted television screen, speaking poetry, and the elevator suddenly drops down to the bottom of the ship. The floor opens, revealing a red chasm below.
The TARDIS is floating in space and the Doctor holds Amy outside the ship by her foot after extending the atmosphere bubble, so she can enjoy the experience of being in space for the first time. Once he brings her inside, he notices Starship UK floating nearby. When Amy wonders what it's doing there, he explains that solar flares devastated the Earth's surface, and the nations of the world built giant ships to escape before the catastrophe. Amy wants to visit but the Doctor insists that he's just an observer and doesn't try to interfere. However, when he scans the ship, he sees Mandy sitting in a mall, crying. By the time Amy realizes what is going on, the Doctor has already landed the TARDIS near the girl and gone out to investigate.
As Amy takes in her first glimpse of the future, the Doctor tells her that she needs to start practicing her powers of observation, and challenges her to look around and see what's wrong. He then grabs a glass of water from a couple and sits it on the deck. Neither they nor Amy know what he's doing. He then points out Mandy to Amy. As they go to talk to her, a robed Winder, Peter, observes their actions and reports by radio to his superior, Hawthorne. Hawthorne says that they are under orders to tell "her" what Peter has seen. Hawthorne then calls the woman, apparently his superior, and tells her that there's been a sighting. She then asks if the Doctor placed a glass of water on the deck. When Hawthorne confirms that he did, the woman dons a porcelain mask and walks to her monitors past a floor covered in glasses of water.
The Doctor points out to Amy that Mandy can't stop crying because she's scared, and that the people avoiding her know what she's scared of and that the source of their fear is everywhere. When Mandy leaves, the Doctor manages to steal her identity kit and sends Amy to follow the girl and find out what she knows. Before Amy goes, the Doctor warns her to stay away from the Smiler booths, the only things kept clean and the only thing that everyone avoids.
Mandy realizes that Amy is following her and turns to confront her. The girl knows that the doctor stole her ID. As the two girls walk, they come to a hole in the hallway. Mandy insists they have to go around, but Amy enters the barrier cloth and tries to pick the lock on the other side. As she does so, Mandy talks about Below, and how no one is supposed to talk to it. When Mandy asks if Amy is the Doctor's girlfriend, Amy nervously denies it and wonders what her past is like now that she's thousands of years in the future. As they talk, Mandy notices a Smiler nearby turning its head to reveal its scowling face. She tries to warn Amy, who gets through the locked barrier. On the other side, Amy finds a giant tentacle extending up out of the floor. She escapes only to find the robed Winders waiting with a captive Mandy. They gas Amy unconscious and take her away.
The Doctor explores the ship and finds a glass of water sitting on the floor. The woman in the porcelain mask, the Masked Lady, confronts him and compliments him on realizing the truth of the ship. She addresses him as the Doctor and asks what the glass signifies. The Doctor explains that since the water doesn't vibrate in the glass, there is no engine vibration and thus no engines. Further, he rips open the power conduits and reveals that they are false, intended only to deceive. The Masked Lady says that he's their only hope and asks for his help. She then gives him a tracking device to find Amy and says she'll meet him again when the time is right.
Amy wakes up in a voting cubicle. The panel in front of her has three buttons: Protest, Record, and forget. Once the computers identify her, a recorded message tells her that she is there because she wanted to know the truth about the starship, and she must now watch a presentation. Once she sees it, she will have to vote. If she protests, and 1% of the ship's population does the same, then the "programme" will end and everyone will suffer the consequences. The recording says that they authorities hope she will forget, because otherwise they are doomed. Amy begins watching the presentation. Once the presentation is done, Amy immediately hits the Forget button. She wakes up with no memory of what she saw or why she chose to forget. Amy discovers she left herself a recorded message and she tells herself to stop the Doctor from investigating and escape with him in the TARDIS.
The Doctor and Mandy arrive and Amy hastily stops the message before he can hear it. The Doctor checks the machinery and determines that it caused Amy to forget the last 20 minutes. Mandy admits that everyone age 16 and older must vote every five years, and everyone has chosen to forget the presentation. The Doctor tries to use the machine but it denies him access because he isn't human. As Mandy stays outside, the Doctor hits the protest button. The door closes and the Smiler in the booth turns its frowning face toward them. The floor opens and they both plummet down into a vast red-hued pit. Outside, the Masked Lady arrives and greets Mandy.
The Doctor and Amy are shoved downward via air cannons and their descent is braked 20 miles down by compressed air bursts. The Doctor quickly realizes that they aren't in the ship's bilge, but rather the mouth of some giant creature. The creature vomits, spewing them out into another chamber. The duo finds themselves in a chamber, and the only way out is to hit a button marked Forget. The Doctor confronts two nearby Smilers in their booths, insisting that he won't forget. Upon hearing that, the Smilers emerge from their booths for the first time and advance on the Doctor. Before they can attack, the Masked Lady breaks in from the outside and shoots them down. She introduces herself as Liz Ten and ushers Mandy in, and then explains that she followed them using a tracker in the device she gave the Doctor. She explains that she has never voted and comes from the outside. Her family was brought up on stories of higher intelligences such as the Doctor, and she heard tales of him passed on by her ancestors, going all the way back to Elizabeth the First.
As the Smilers start tor repair and advance again, the Doctor realizes that Liz Ten is the tenth-generation ancestor of the queen. Liz Ten gets them out of the chamber and they enter a room filled with more of the giant tentacles. The Doctor realizes that they are breaking through walls all over the ship and suspects what is truly going on. Amy notices him putting the pieces together and remembers the message she left herself to stop the Doctor from investigating. Meanwhile, Hawthorne watches them on the monitors and then activates a security protocol.
The quartet go to Liz Ten's quarters and she tells them that the glasses on the floor are to remind her of the tyrannical ship's government. Amy is surprised that she's so young and Liz Ten explains that the scientists on board have slowed her biological clock. When she discovered that the Winders were keeping secrets from her, she donned the porcelain mask and went to investigate. The mask is a family heirloom. The Doctor is intrigued by the fact that the mask is a perfect fit.
The Winders arrive and Peter prepares to take Liz Ten into custody. When she insists that as the Queen, she can't be taken, Peter reveals why he and the others are called Winders: their heads rotate, revealing frowning Smiler masks in the back. When Liz Ten insists that no one has the authority to order her capture, Peter agrees that only she has that level of authority... and then takes her away.
The Doctor, Mandy, Amy, and Liz Ten are taken to the dungeon in the lowest part of the starship. Several of the emerging tentacles have been confined in a large cage. Liz Ten confronts Hawthorne, who is impressed that the creature spared the Doctor and Amy. Those of low-value are fed to the Beast, but it refuses to eat the children. The Doctor discovers a vast brain-like tumor in the chamber floor and realizes that the Winders use electric prods to torture the creature. The creature is a Star Whale, and the ship is built on and around it. It is a tortured prisoner, forced to carry the citizens of the UK to safety.
The Doctor uses his sonic screwdriver to let the other hear the intense pain that the creature suffers. Hawthorne continues to insist that he is acting on the highest authority, and ignores Liz Ten's orders. The Doctor realizes who ordered Hawthorne: Liz Ten. He points out that her porcelain mask is a perfect fit, and yet it's over 200 years ago. The scientists have kept her alive for centuries. She doesn't remember because she has cast her own vote. The Doctor discovers a panel with two buttons; Forget and Abdicate. Hawthorne admits that they are following her orders, and the Doctor plays a message Liz-Ten made to herself in case she was brought to this chamber. On it, Liz Ten explains that the British government captured a Star Whale as it came near Earth in the final days of the planet's existence. Unable to build a spaceship in time, they captured the Star Whale and converted into a starship, allowing them to escape.
Liz Ten must now make the same decision she has faced many times before: Abdicate, and release the Star Whale and doom her people. Or Forget for another 10 years. Amy wonders why she chose to forget, and the Doctor rounds on her. He accuses her of taking the decision he ultimately had to make upon herself, so that he wouldn't have to choose between leaving the Star Whale imprisoned for an eternity or dooming the ship's passengers. Disgusted, he tells her that he'll be taking her home and dropping her off when they are finished. Amy protests, insisting she's only human, but the Doctor ignores her. The only thing he can do is lobotomize the Star Whale so that it will function but be incapable of suffering. When Liz Ten and Amy object, he tells them that they have nothing to say to him, and when he has lobotomized a living creature, he will no longer be the Doctor.
The Doctor prepares to lobotomize the Star Whale, and Timmy and the other children come in. One of the tentacles touches Mandy tenderly, and Amy notices it. Realizing what is truly going on, Amy grabs Liz Ten's hand and puts it on the Abdicate button, and tells the Doctor to stop. The starship begins to shake violently. Hawthorne and the others wait for the inevitable, only to discover that the Star Whale is accelerating rather than shaking them all loose from its body. Amy explains that the Star Whale came to Earth to assist. It volunteered its services but the British, unaware of its true nature, imprisoned it and forced it serve them through torture. It had no intention of letting the children die, and will continue to serve willingly as their starship.
Later, Amy comes to get the Doctor and gives him Liz Ten's mask. She promises him that she won't keep any more secrets from him. When the Doctor points out that she could have killed everyone onboard, Amy points out that he would effectively have killed the Star Whale. She admits that she knew what it was feeling because she has seen another ancient being, the last of its kind, who took pity on children no matter what the cost. The Doctor hugs Amy and they go back to the TARDIS.
As they dematerialize, Amy wonders if the Doctor can keep his promise to take her back on the morning after she left with him. She asks if he's ever ran away from something he wasn't ready for, and the Doctor admits that he did, once. Amy considers telling him the truth about her wedding, but is interrupted when a phone rings. She answers it and discovers that it's Prime Minister Winston Churchill. The Doctor takes the call and Churchill warns him that he has a tricky situation on his hands and needs the Doctor's help. The Doctor agrees to be there, unaware that a Dalek lurks behind Churchill in his office.
As the TARDIS leaves, the Star Whale continues on its journey. What no one is aware of is that there is a crack in its side, a glowing crack like the one in Amy's bedroom.