It is January of 1967, and young Jessica Willamy, a.k.a. Summer, is searching Haight-Ashbury for her missing boyfriend Denny when she meets the Doctor in the crowd. A boy who appears to be tripping out walks up to the Doctor and shows him the cloth-faced head of a robot which he and his friends Ben and Polly recognise as a Cyberman. The robot head vanishes into thin air, and the panic-stricken boy flees, claiming to have seen the Devil. Summer follows the Doctor back to a police box in the park, and, perhaps just to be rid of her while he investigates his own problem, he asks Ben and Polly to help her look for Denny. At the I-Thou coffee shop, Ben and Polly tell Summer their own amazing story, and Summer explains that she and Denny met when he saved her from a group of rednecks outside a bar in Amarillo; she’s convinced that he would never abandon her without a word unless something terrible had happened to him.
As Summer speaks to Ben and Polly, another customer begins to scream, claiming that she saw a man melt away into thin air. Someone else mentions Blue Moonbeams, a kind of drug which it’s said has been causing people to vanish, and Summer, Ben and Polly decide to investigate. They stop in at the Oracle, where reporter Jack Stimson admits that kids have recently begun to vanish; however, there are any number of unpleasant plausible explanations. Haight-Ashbury is filled to bursting with outsiders, not all of whom are idealists. Nevertheless, Stimson agrees to keep an eye out for Denny. Outside, Summer meets the Doctor again, but he’s off on his own train of thought, convinced that the head of the Cyberman was a deliberate message to him. Summer is upset by his apparent lack of concern for her plight, but his musings seem confirmed when another tripping man steps out of the mist, accompanied by a Menoptera which gestures enigmatically and then vanishes. Summer returns to her pad, still unsure whether to trust the Doctor, whose agenda is so alien as to be incomprehensible.
The next morning, Stimson informs Summer that someone matching Denny’s description was seen speaking to the Goblin, one of the most dangerous people in the Haight. Summer determines to investigate, but her friends are too frightened of the Goblin to accompany her, and the Doctor claims to be too busy with his own problem to help her. Upset, Summer goes to the Goblin’s house on her own. Inside, she finds a woman on a bad trip who claims that there are colour-beasts everywhere, and as Summer watches, something invisible drags the woman out of her chair and into the shadows. Terrified, Summer flees upstairs, where she meets the Goblin, a vicious drug dealer preying on the innocents of Haight-Ashbury. He claims that the Blue Moonbeams are nothing to do with him, and indeed seems angry that the witch Mathilda and her friends are trying to put him out of business. Summer demands to know what’s happened to Denny, and the gloating Goblin shows her Denny’s shirt, which is drenched in blood. He then tries to rape her, but at the last moment Ben and Polly show up and help her to escape. Furious, the Goblin vows revenge on them all.
Summer eventually pulls herself out of her grief and determines to do something, convinced that Denny was murdered because he learned something about the Blue Moonbeams. The Doctor agrees to accompany her to a party at Mathilda’s house, but Summer realises that he’s doing so not for her but for his own reasons. At the party, a man bursts out from a private room in the back of the house, his skin melting away into coloured lights to reveal the muscle and bone beneath. Mathilda’s masked followers then force Summer, the Doctor, Ben and Polly into the back room, and in the struggle, Ben knocks free one of his assailant’s masks to reveal an ordinary, cold-eyed man with a crew cut. The masked figures force the four to take Blue Moonbeams and then lock them up with the drug’s other victims, but Summer spits hers out, the Doctor palms his, and they induce vomiting in Ben and Polly. The others in the room are falling victim to the drug already, and as Summer and her friends flee, the hippies begin to vanish into thin air -- and Summer hears the sounds of terrible fighting and violence from the room.
The Goblin is still hunting Summer and her friends, complicating their attempt to find out why Mathilda is apparently killing her customers. The Doctor tries to enlist Stimson’s help, but he’s busy preparing for the Human Be-In, a festival which will kick-start the Summer of Love... and a perfect opportunity for Mathilda to distribute Blue Moonbeams to the entire population of Haight-Ashbury. The Doctor analyses the tab he stole from the party, develops a chemical which should be able to neutralise the remaining stash, and sends Summer, Ben and Polly to Mathilda’s house; however, they find it abandoned. As they ponder their next move, the Goblin and his gang track them down, but before he can kill them something invisible rips into him and his gang, tearing them all apart. Summer, Ben and Polly barely escape with their lives, and Summer fears that Mathilda summoned a demon to destroy the Goblin before he could go after her.
The Doctor has worked out that something is trying to communicate with him using symbols from his own memories: the Cybermen, humans who turned themselves into machines; components from WOTAN, small pieces of a larger, malign organisation; and a Menoptera, one of a species which naturally metamorphoses from ugliness to beauty. The Doctor now appears far more supportive of Summer, and assures her that she doesn’t need Denny to take care of her. However, Summer feels that the innocence and love of the Be-In has been tainted by the threat hanging over it. As she and her friends stake out the Polo Grounds, another hippie approaches the Doctor, and as colours pour out of his body the earth begins to quake, the final clue to the location of the creature which is trying to make contact with the Doctor.
Summer sees Mathilda and her followers passing through the crowd, distributing their drugs, and catches a glimpse of something so terrible that she rushes forward to confront Mathilda before she realises what she’s doing. She impulsively seizes the bag of Blue Moonbeams and flees, losing herself in the crowds. She and her friends then set off in search of the Colour-Beast, accompanied by Stimson, whom they’ve filled in on events. The hippie whom they saw bleeding colour at the Be-In directs them to a hidden doorway which leads to the ruins beneath the city; contemporary San Francisco was built atop the ruins of older buildings buried in the earthquake of 1906.
The Doctor explains that the girl at the Goblin’s house could see her attackers because the LSD she’d taken altered her perceptions. Summer agrees to take a new drug which the Doctor has developed to alter her perceptions without exposing her to the dangerous side-effects of acid. The others reluctantly wait outside while the Doctor and Summer pass through the doorway, where they find a secret laboratory complex occupied by the dead-eyed, crew-cut men who hid beneath masks at Mathilda’s party. Summer follows her heightened senses to a room where a huge alien has been chained to the floor; its skin colour changes so rapidly that the human optic nerve overloads and fails to register it, effectively rendering the alien invisible. The Colour-Beast communicates telepathically with Summer, revealing that it has been trapped by corrupt figures in power who are using an extract from its blood to create human/alien hybrids. The stress of the change turns the invisible hybrids into psychotic killing machines until they burn out from the stress.
The Doctor and Summer are captured by the crew-cut men in grey, who have already disposed of Mathilda as a loose end. Just as they are about to do the same to the Doctor and Summer, Ben and Polly disobey the Doctor’s orders, track them down and rescue them. The Doctor, Ben and Polly remain to free the Colour-Beast while Summer returns to the Be-In to prevent those who have taken the Blue Moonbeams from slaughtering the innocent. At the Polo Grounds, however, Summer again sees the terrible thing she’d glimpsed and refused to believe earlier, and can no longer deny that one of the masked figures is Denny. He has been seduced by the promise of power and turned his back on the ideals Summer thought they shared. He has been helping to distribute the Blue Moonbeams, and was nearly killed by the Goblin when he tried to get rid of him so there’d be less competition and more demand for Mathilda’s drugs.
Shaken by this utter betrayal, Summer can do nothing as the victims of the Blue Moonbeams begin to transform into killers -- but at the last moment, the freed Colour-Beast arrives and lingers just long enough to reverse the process before departing from Earth. The grey men are forced to retreat, having failed to destroy the Summer of Love which they’d regarded as a threat, but before going, Denny warns Summer that she knows too much now; for the sake of what they once had, he advises her to get out of town before the grey men decide to clear her up as one of the loose ends.
Summer leaves San Francisco without looking back and goes on the run for decades, watching in despair as the ideals of her youth are corrupted and forgotten. As she grows older and more cynical, she comes to believe that her kind never stood a chance against their enemies, because the corrupt will do whatever it takes to hold onto what they have. Every so often she catches a glimpse of Denny on the news, and realises that there’s no trace left of the man she loved. Finally, nearly forty years later, living in an isolated house in New England, she starts to hear clicks on her phone line, finds that her mail is being opened, and realises that Denny is coming to deal with her at last. But even as a mysterious car turns into her driveway and she sits waiting with a gun in her hand, the Doctor’s police box materialises behind her and a man in a floppy hat and long scarf steps out, claiming to be the Doctor she once knew. He tried to find her after the Be-In, but it’s taken him this long to track her down. He knows he seemed aloof at the time, but that’s only because he wanted her to solve her own problems rather than relying on him to do so. As the assassin breaks into the house, the Doctor shows Summer a book due to be published next year -- Jack Stimson’s expose of the conspiracy -- and she realises that there is hope after all. She puts the gun aside and departs with the Doctor, leaving Denny and his kind far behind.