On Gallifrey in the distant past, two repairmen get an alert that someone is stealing a TARDIS in for repairs.
Clara tries to work out where she is, and why she keeps running into the Doctor in all of his incarnations, and is always trying to save them.
In 1893 London, prisoner Clarence DeMarco sits in a cell and mutters about the Whisper Men. Vastra comes to see him and Clarence offers her valuable information in return for his life. When Vastra says that he's killed 14 women and nothing is that valuable, Clarence mentions the Doctor. The prisoner says that he's heard whispers in the pattern of the word, the Doctor's secret that he'll take to the grave... and someone has discovered it.
Back at her home, Vastra tells Jenny about Clarence's offer. She says that Clarence alive until they learn what he knows, and goes to prepare a conference call. As she goes to make the arrangements, Jenny sees someone outside and hears whispering. Vastra interrupts her to ask where Strax is, and Jenny tells her that he's taking his normal weekend off.
In Glasgow, Strax is fighting in a bar when a messenger boy arrives with an urgent telegram from Vastra. Once he sees that she wants a conference call, Strax asks his opponent, Archie to knock him unconscious.
In London, Vastra and Jenny prepare a table and go to sleep. They find themselves in a dream reality conference room with Strax. When he notices that there are five teacups, Vastra says that two women will be joining them.
Clara is making soufflés for Artie and Angie when she notices a letter that came for her, that says to open when alone. Once she is, Clara opens the letter and discovers that it's from Vastra. Vastra asks Clara to light the enclosed candle, putting her into a trance state. However, the Siluarian also tainted the paper with the same drug just in case.
Clara passes out and finds herself in the conference room. River Song appears, summons her own glass of champagne, and glances at Clara. Vastra introduces her and gets down to business. She shows them a series of space-time coordinates that Clarence offered in return for his life. The coordinates are the location of the Doctor's greatest secret, but they don't know what it is. Clara is surprised to learn he has secrets, and Vastra points out that Clara doesn't know the Doctor's real name.
Someone breaks into Vastra's house and passes Jenny, and she notices it in the dream world. Meanwhile, River says that she knows the Doctor's name, but explains that she hasn't heard from him in a long time. Vastra explains that Clarence told her one more word that confirmed he was speaking the truth: Trenzalore. River says that they misunderstood what Clarence said. Jenny interrupts to say that she forgot to lock the door and warns that someone is with them. She begs Vastra for forgiveness and says that she's been murdered.
Jenny fades away and River slaps Vastra, telling her to wake up. The Silurian wakes up and discovers the eyeless Whisper Men have gathered around Jenny's body. River wakes up Strax next, and he finds himself surrounded by more Whisper Men. More of the Whisper Men appear in the dream reality and the Great Intelligence appears, telling River that the Doctor's friends are lost unless he goes to Trenzalore.
As River says that the Doctor can never go to Trenzalore, Clara wakes up in her bedroom as the Doctor calls out. He's there calling out for Angie and Artie, who he thinks is playing Blind Man's Bluff with him. Clara removes his blindfold and tells him that the children went to the cinema. She tells him what happened and asks about River, and the Doctor says that she's an ex. The Doctor has Clara recite what she heard, and briefly breaks into tears at the news. He then runs out to the TARDIS and Clara goes inside after him. The Doctor explains that he's heard the name Trenzalore before but never wanted to go there and find out. He links Clara into the TARDIS telepathic circuit to get the coordinates from her mind, and explains that Trenzalore is where he's buried, somewhere in his future.
The Doctor sets the coordinates for Trenzalore to save his friends, and Clara insists on going with him. The TARDIS resists when it realizes where they're going to cross the Doctor's timeline. The console room explodes in sparks as the Doctor tries to maintain control, and the TARDIS shuts down rather than land. The Doctor looks outside and discovers that they're in orbit above Trenzalore. He turns off the anti-grav and the TARDIS plummets toward the planet's surface. Once they're down, the Doctor emerges and discovers that the TARDIS window is cracked. He warns Clara that his grave is potentially the most dangerous place in the universe and they make their way through a battlefield cemetery filled with gravestones. The higher the rank, the bigger the gravestone. The biggest gravestone is an enormous representation of the TARDIS, towering over all the rest. The Doctor explains that it actually is a TARDIS. When it died, its internal dimensions started leaking out, making the exterior larger.
As the Doctor approaches his grave, River appears to Clara. She explains that the Doctor can't see her, but Clara can since they're mentally linked. The Doctor comes back and says River's name... because he sees her gravestone. Clara says that River isn't dead, but the Doctor says that she has been for a long time. However, he insists that River can't have a gravestone on Trenzalore. A group of Whisper Men approach them, and the Doctor tries to drive them off without effect. Meanwhile, River suggests that the gravestone is a secret entrance to the tomb, and Clara echoes her comment. The Doctor realizes it's a trigger and activates it, mentioning that River is his wife, and he and Clara plummet down a shaft.
Vastra wakes up next to Strax in the TARDIS tomb and realizes where she is. When Strax wakes up, he immediately calls on his kidnappers to surrender. Jenny is lying nearby, dead, and Vastra begs him to bring her back. Once he confirms she died of shock, Strax revives Jenny's heart. The Great Intelligence, using Simeon's body, arrives with his Whisper Men, and welcomes them to the tomb of the slaughter of the ten billion… the Doctor.
As the Doctor and Clara make their way through the catacombs, River tells Clara that when she died, the Doctor saved her to a database in the Great Library. A Whisper Man advances on Clara and the Doctor grabs her and runs.
Simeon explains that the Doctor was killed in a relatively minor skirmish. When Vastra doesn't believe that the Doctor is a tyrant, Simeon says that the Doctor has killed billions. Vastra wonders how Simeon knows so much about the Doctor's history, he explains that he is a bodiless datastream. Simeon removes his face and his body collapses into nothing, and the Intelligence shifts its being into one of the Whisper Men.
The Whisper Men grab Clara and pull her back. The Doctor pulls her free and slams the door in their faces. As they continue on, Clara falters and then remembers experiencing something similar when the TARDIS crashed... something that she can't remember because the Doctor rewove time. The Doctor warns her that the TARDIS' telepathic circuits are remembering memories she shouldn’t have, and Clara remembers how he said that he kept meeting her throughout time and watching her die. The Whisper Men's voices echo through the chamber, saying that the Doctor will die again, and the Doctor runs on with Clara.
Simeon tells his prisoners that the doors require a key: the Doctor's name. The Doctor arrives and Simeon tells him to open the door. He refuses to open his tomb and Simeon tells the Whisper Men to stop the captives' hearts. Strax swings at one but its body is insubstantial. They pass their hands into their victims' chests, but the Doctor still refuses.
The tomb doors open and Simeon orders the Whisper Men to stop. River tells Clara that the TARDIS can still hear her, so she gave the name. The Doctor runs to Clara and hugs her, and then asks Simeon if he knows what he now has. Simeon says that he will have peace, and the Doctor will have everlasting pain. The Doctor has no choice but to lead them in to what was once the console room. The room is covered in vines and a glowing helix of energy stands in the center. The Doctor explains that it's the scar tissue of his journey through the universe, from Gallifrey to Trenzalore.
The Doctor collapses from the inherent paradoxes, and Simeon walks toward the column. He explains that once he enters it, he can rewrite the Doctor's history, reversing every victory and destroying every friendship. Simeon is well aware that he will be scattered along the Doctor's timeline, but doesn't care as long as he has his revenge. The Intelligence enters the rift and disappears, and the Whisper Men fade away as Simeon appears through the Doctor's timeline, killing him in every incarnation as his current body writhes in agony.
Vastra monitors the time rift and detects all the times where the Doctor is dying. She mentions the Dalek Asylum and Clara tries to remember what happened there and how she saved the Doctor. Vastra, Jenny, and Strax go outside and watch as the stars wink out one by one. When Vastra turns back to Jenny, remembering how the Doctor saved her, she discovers that her wife is gone. Strax no longer recognizes Vastra and, reverting to typical Sontaran behavior as his past changes, attacks the Siluarian. She has no choice but to disintegrate him with an energy pistol.
Clara realizes that she has to enter the time rift. The Doctor begs her not to, but Clara says that she's already done it and that she's gone into the past to save him. River appears and tells her not to, explaining that the Time Winds will tear her apart and create a million version of her, living and dying throughout time and space. Clara figures that even if she dies and her copies live on, that will be enough. When Vastra returns, Clara tells her to get out as fast as she can and remember her. She tells the Doctor that if he sees her again, then to "Run, you clever boy," and remember her. Clara jumps into the rift and splinters throughout time, helping the Doctor again... and again... and again.
Once the timeline is restored, Strax apologizes to Vastra. The Doctor plans to go back through the rift and rescue Clara. When Vastra warns him that Clara is dead, he tells her that she has one advantage: him. The Doctor tells them to go to the TARDIS and use the fast-return protocol if he doesn't return. The data ghost of River tries to tell him to find another way, and slaps him in frustration... and the Doctor catches her hand. He explains that she's always been there for him and he can always see her. When River wonders why he didn't say anything, the Doctor admits that he thought it would have hurt too much. He kisses his wife and wonders why she hasn't faded away. River says that it's hard to leave when he hasn't said goodbye. When he wonders how to do it, River tells him to say it like he plans to come back. The Doctor steps back and then says that he'll see her around.
River says that there's one more thing and points out that she's mentally linked to Clara. If Clara is dead, then River couldn't be there. However, she refuses to tell him how she is there, citing "spoilers," and fades away. The Doctor turns and braces himself, and then steps into the rift.
Once the Doctor is safe, Clara lands on the surface of an alien planet. She calls to the Doctor and he responds, saying that she's inside his timestream. Incarnations of the Doctor run past as the Doctor explains that they represent every good day and every bad day. His timestream is collapsing in on itself but he won't leave until she's safe. The Doctor sends her something from her past: a leaf, drifting down on the wind. He tells her to hold onto it and it will take her home, and he becomes visible. When Clara wonders how she can go to him, the Doctor tells her that she's his impossible girl. The Doctor asks her to trust him and let him save her for once. Clara walks toward him and they embrace.
As they hug, the Doctor sees a figure standing nearby, facing away from them. Clara wonders who it is and the Doctor says that it's him because he's the only one there. She says that she saw all of the Doctor's faces and it wasn't one of them, and the Doctor says that while the figure is him, it's not the Doctor. The Figure is the one who broke the promise that the Doctor made... his secret. Clara faints from the strain and the Figure says that he had no choice but to do what he did... in the name of peace and sanity. The Doctor admits that he did... but not in the name of the Doctor. As the Doctor turns and walks away, the Figure from the Doctor's past watches him go.