Moments after materialising near a fantastic city of gleaming towers and elevated roadways, Compassion withdraws into herself, focussed on something beyond the dimensions which the Doctor and Fitz can perceive. The Doctor is unable to draw her attention, but his curiosity gets the better of him and he sets off with Fitz to explore, telling himself that Compassion will be all right. As they approach the city, figures dressed in animal skins and wielding axes attack them and capture the Doctor. Fitz flees into the city, only to find once he gets there that it has been vandalised and is all but deserted. He is captured by thugs on antigravity motorcycles, and taken to a milk bar where the rockers are awaiting an attack by their enemies, the mods. Fitz is interrogated by the rockers’ suspicious leader, Alec, but picks up on cues in his questions and improvises wildly, claiming to be a saucer pilot who crashed here on his way to Mercury. Alec sends the rockers out to find Fitz’s passenger, the Doctor, before the cannibals who live outside the city get to him.
Another party of rockers arrives with both a prisoner and bad news; the mods have somehow made a technological breakthrough and are now armed with ray guns. The prisoner, Davey, refuses to tell Alec anything, but before Alec can lock him up the mods attack the rockers’ milk bar. Fitz instinctively intervenes before a rocker can shoot Davey with the confiscated ray gun, and is forced to flee with the mods when the angry rockers turn on him. They return to the mods’ hangout, and Fitz meets Davey’s grateful parents, Deborah and Vince, who must have been in their teens when Davey was born. While waiting for the mods’ leader to speak with him, Fitz elaborates upon his supposed origins as a shuttle pilot, using his experiences on Mechta to provide detail. He runs into trouble, however, when he has to bluff knowledge of the city’s numerous labour-saving devices, including antigravity lifts, food machines that dispense tasteless pills and protein shakes, and automatic dressing machines which clothe him in the uniform of a mod before he realises what is happening.
The Doctor finds the “cannibals” to be dropouts who left the pointless war of the city-dwellers behind them; they are labelled as such because they eat the bodies of their dead in an attempt to shake off their reliance on the city’s food machines. Although the city remains the planet’s only source of oxygen, the Doctor teaches the outsiders how to extract nutrients from the otherwise poisonous plants in the wasteland. The rockers arrive and claim that Fitz has joined them, and the outsiders, grateful for the Doctor’s help, allow him to depart peacefully. On the way back to the rockers’ bar, he is told that this is the planet Earth and the year 2019 AD. Alec orders him to duplicate the ray gun to ensure that the mods do not achieve technical superiority, but the Doctor refuses to become involved in a pointless arms race. The rockers’ Technician, Gillian, upset that the Doctor has taken over her laboratory, ignores his warnings out of spite, and is badly burned when she tries to take apart the ray gun and shorts out its power pack. She is forced to go for medical treatment, and the Doctor takes the opportunity to escape -- from the laboratory, at least. By the time Alec and the rockers catch up to him, he’s managed to explore most of the complex and has come to certain conclusions. This is neither Earth nor 2019, and the city is disintegrating on a molecular level. Unless he can find the cause soon, the city will cease to exist, and the mods and rockers will all die from lack of air.
Alec and his wife Sandra finally admit to the Doctor that they were transported here twenty years ago from the year 1965. Sandra’s two older brothers were mods who opposed her relationship with Alec, and Sandra eventually realised that Alec wasn’t fighting them because he loved her, but because of his pride. Knowing that a big rumble was due, she tried to talk some sense into Alec -- but as they argued an alien ship suddenly appeared on the beach before them, and they forgot about their empty lives for a few hours while they nursed the injured alien back to health. The alien assembled a new ship out of the sand on the beach and vanished -- but two days later, during the rumble which Sandra had failed to avert, all of the mods and rockers were transported to this futuristic city. They assumed that they had been transported to a space age city of the year 2000 AD, and since it was uninhabited and the world beyond the city was airless, they concluded that humanity had wiped itself out in a nuclear war and that the alien had brought them here to repopulate the Earth. But over time, the old rivalries reasserted themselves, and for years now the mods and rockers have been at war -- and although the servo-robots and the city’s Brain have always been able to repair the damage until now, lately it appears that things have been falling apart more quickly than they can be put back together. Alec is convinced that the mods have acquired their ray guns by accessing the Brain, and that in so doing they have somehow damaged it; he is therefore determined to wipe them out once and for all. The Doctor returns to the laboratory, where he finds that Gillian has damaged the ray gun beyond repair in her attempts to understand it. Realising that she is working herself to exhaustion, the Doctor builds a low-frequency sonic generator which puts her to sleep, and then starts work on a larger version.
Fitz is brought before the mods’ leader, Sandra’s young brother Rick, who was three years old when he was brought to the city. He is now in his early twenties, but still has the temperament of a dangerous child given to abrupt mood swings and furious rages when he doesn’t get his own way. He demands that Fitz supply him with the technology from his crashed ship, and when Fitz claims that it was all destroyed in the crash, Rick sends Davey out to check for himself. Davey finds Compassion, who at first doesn’t even seem to notice him. Furious with Fitz for lying to him, Davey tries to drag Compassion back to the city, but she senses his presence and tries to communicate with him telepathically -- and he passes out from the shock of seeing his entire pointless life from her perspective in one blow. By the time he recovers, she has finally noticed that the Doctor and Fitz have been gone for hours and has gone to the city to search for them. He returns to the city and reports failure to Rick, but Rick seems strangely calm about it and simply tells him to rest up for the big rumble... and to keep an eye on the treacherous Fitz.
Fitz spends an uncomfortable night on a flat metal bed without realising that it is supposed to support him in an anti-gravity field when switched on. The mods plan to attack the rockers’ bar with their new ray guns, and Fitz is disappointed to see that Deborah and Vince are participating in the rumble as enthusiastically as the rest. In 1965 they had been neither mods nor rockers, but innocent bystanders who got caught up in the rumble while going out to a movie to take their minds off Deborah’s unwanted pregnancy; however, once transported to the city with the others, they were forced to choose a side in order to stay where there was shelter and food. Fitz tries to make a break for it when the attack begins, but the enraged Davey pursues and captures him, and he is locked up for treason back in the mods’ base. Meanwhile, Rick tries to communicate with his new “guest” -- Compassion, who has been drawn to the mods’ hangout by the sense that there is another mind here like hers...
The mods break into the rockers’ bar, but retreat back out into the courtyard just as they appear to be winning -- and the rockers pursue them into an ambush laid by flying mods on jetpacks. The Doctor arrives with his sonic stunner, which he uses to drive off the mods; however, he doesn’t understand why they fled the milk bar at all when they were clearly winning, just for a chance to show off their new toys. But when an unfortunate rocker named Matt is electrocuted by a servo-robot trying to attack Alec, the Doctor realizes that the attack was just a diversion so Rick could smuggle in an assassin programmed to kill Alec. He deactivates the killer robot, but still insists that the survival of the city takes priority over the war with the mods, and sets off with an oxygen mask to see what lies beyond the city borders. Sandra, who has had enough of the war herself, accompanies him, and they discover that the city is surrounded by an invisible energy barrier; mods and rockers alike are all prisoners inside a giant glasshouse.
Alec, infuriated by the Doctor’s and Sandra’s disobedience and feeling that events are getting out of his control, takes out his frustrations while interrogating a mod prisoner and accidentally kills him. To cover his mistake, he orders his rockers to dump the body near the mods’ hangout as a warning. Davey and his friends try to take out their anger on the captive Fitz, but before they can seriously harm him Rick orders that Fitz be brought to him in one piece; Compassion still will not speak to him, and Rick needs Fitz to make her talk. He has locked her up with his other prisoner, the one only he knows exists -- the alien from the beach, who returned to the city only to be imprisoned by Rick and forced to build him ray guns and jetpacks. Compassion reveals to Fitz that communication with the alien, the Maker, has shown her a new perspective on time and space, and that it has become difficult for her to focus on the basic three dimensions. She tries to share her perspective with Fitz, but the flood of information nearly drives him mad; however, he survives, with an understanding of the Maker’s intentions. It felt grateful when Sandra and Alec rescued it on the beach, and, realising that they could not perceive the fourth dimension and thus could not navigate towards their desired future, it decided to reward them by taking them to the future they imagined. And since no such future existed, it built one for them.
The city continues to deteriorate, and the antigravity lifts begin to malfunction, causing the death of a rocker. At first Alec insists that the mods have sabotaged them, but apparently sees reason and “allows” the Doctor to take a look at the city’s Brain. Gillian insists upon accompanying him, however, and Alec can’t think of a way to stop her without making the Doctor suspicious. He has in fact attempted to send people to the Brain before, but nobody has ever returned, and he hopes that a threat to his life will force the Doctor to circumvent the Brain’s defenses. When Sandra learns that Alec has effectively sent the Doctor and Gillian to their deaths, she realises there is no reasoning with him and that her hopes for peace are in vain. She only married Alec because she thought it would bring the two factions together, but her older brothers caused trouble at their wedding; and since there were no authority figures in the city to stop the rumble from getting out of hand, people died, leading to the state of war which exists today. Sandra’s older brothers died long ago, she hasn’t seen Rick for years, and neither the mods nor the rockers trust her since she changed sides. Realising at last that Alec will never grow up, she leaves him.
The Doctor and Gillian slip into the central computer complex when a servo-robot enters for maintenance, and inside they find the Brain, a giant reel-to-reel computer which promptly tries to kill them, as it does any intruder who threatens it. The Doctor manages to convince it that it is not logical to kill him until it knows whether he can help it prevent the collapse of the city. The Brain thus explains that the city’s deterioration is exponential, and that it has less than two days to survive. Since it cannot save the city, the Doctor convinces it to switch off itself and all non-essential services, hoping that the extra power will give the mods and rockers time to understand the extent of the crisis. But to his frustration, when Alec and the rockers arrive they demand that he switch the Brain back on so they can use it to defeat the mods. Desperate to prove that he is still in charge, Alec has his rockers attack the Brain and its components until the Doctor, fearing that they may damage the oxygen generators, agrees to reactivate it. He is too late, however; the rockers have irreparably damaged the Brain, and as Alec watches the giant computer begin to melt away, he finally realises that the Doctor was right all along, and that the city is doomed.
Sandra arrives at the mod headquarters, only to find that Rick is even worse than Alec. He still blames her for trying to leave him behind in 1965, where as a child he was always talked down to and couldn’t always get what he wanted; this city is like a giant playground to him, and he never believed that she didn’t want to come here at all. He tries to use her return as a triumph, proof that she couldn’t tolerate life with the rockers, and in desperation she finally reveals that he is not her little brother, but her son -- a fact which her family kept secret from the rest of the town. Devastated and furious, he refuses to believe her and orders the mods into battle; while they attack the rockers outside the computer complex, he will force the Maker to give him an ultimate weapon and destroy the rockers’ bar for good.
Compassion reveals to Fitz that it is the Maker who is destroying the city. The Maker is but one aspect of a gestalt entity, and does not differentiate between individual humans; thus, since Rick has imprisoned and tortured it, it feels betrayed and is taking back its gifts. Rick arrives and demands an ultimate weapon, and the Maker -- who does not care if the humans start killing each other -- supplies him with a tank equipped with a giant drill bit. In his eagerness to use his new toy, Rick fails to notice that Fitz has remained in the mods’ hangout while the others attack. The rumble begins, and as Rick drills throught to the rockers’ base, his mods attack the rockers outside the Brain. Davey is stabbed as he tries to get to Alec and kill him, but then the entire city seems to blink out of existence for a second. More Makers have arrived to take their revenge, and as they begin to hunt down the humans and kill them, the mods and rockers finally realise just how petty their squabble is in comparison to the forces at work here. Davey dies of blood loss, knowing that everything he has fought for all his life has been for nothing.
Fitz, Sandra, Deborah and Vince head for the Brain complex, only to find Rick and Alec at each others’ throats once again; Alec blames Rick for turning the Makers against them, while Rick blames Alec for destroying the brain. Sandra is furious; have they learned nothing? The Doctor tells them that, stuck in a city without entertainment or diversion, without a purpose in life or a goal to strive for, the mods and rockers turned to their hatred of each other as the only thing to keep them going. They have wasted the last nineteen years of their lives; the Makers did not give them a future, but took it from them. Subdued, Alec, Sandra and Rick accompany the Doctor back to the mods’ hangout, where Compassion is waiting with the Makers. Once they see the humans clearly, the Makers perceive the changes they have caused to their lives and the damage they have done, and finally understand their mistake.
The Makers halt the collapse of the city and offer the survivors a choice; they can either insert them into history as ordinary citizens of the real year 3012, or they can return home to 1965, restored to youth and living out the rest of their lives in peace. If they choose the latter, however, their time in the city will never have happened, and they will thus remember nothing of it. Rick refuses to accept that his life here is finished and tries to kill the Makers, but the Makers defend themselves by trying to communicate with him -- and the moment of total perception drives him mad. He may recover and attain a new perspective, or he may remain mad for the rest of his life. Sandra decides to remain in the year 3012 with him, unwilling to forget the lessons she has learned. Gillian also decides to remain, as the Doctor has shown her that there is more out there than she’d ever dreamed of, and she doesn’t want to forget what she has become. Alec, however, is only too happy to return to the past, and Deborah and Vince choose to return as well, hoping to give Davey another chance at a better life.
As the people of the city make their own decisions, Compassion informs the Doctor that despite the new perspective that the Makers have shown her, she has decided to remain with him; she is happy being who she is. The Doctor, Fitz and Compassion depart, leaving the former mods and rockers to make their own future. Alec returns to 1965, where he and Sandra’s brothers blame each other for driving her to run away with Ricky, and Alec gets his rocker friends together to teach Sandra’s brothers a lesson. He was never in the city, and thus has learned nothing from it.