The episode begins with a small montage of Clara Oswald travelling through time then we see the Paternoster Gang meeting. Madame Vastra from the gang has called a meeting, Vastra enters a sleep mode with Jenny and an invitation is sent to Straxx to be summoned . Straxx is in the middle of a fight and ends it quickly when he gets the summons. Straxx is having a fight in Glasgow at the time.
Clara is looking after some children when she gets the summons. Clara receives a letter which turns out to be a summons to the meeting from Vastra and falls asleep. Also joining them is River Song. During the meeting, Jenny disappears and eventually, faceless men from the Great Intelligence break into the dream and end it.
When Clara wakes up, The Doctor is in the flat with a blindfold playing a game. The children Clara was looking after have disappeared. Clara tells The Doctor about the dream and then they rush to the TARDIS to travel to Trezalore, the burial planet of the Doctor. The planet is dark and there is no life on the planet, there is only gravestones of the TARDIS, the Doctor and River Song. River Song appears to Clara but the Doctor cannot see River according to River.
The Doctor and Clara use a gravestone to get into the catacombs under the planet where they are confronted by the Great Intelligence led by Dr. Simeon played Richard E. Grant. Simeon takes the Doctor to the TARDIS and tries to force him to say the Doctors real name so they can get inside the TARDIS tomb but the Doctor refuses. River Song appears and is the person who says the Doctors name but no one hears it except the TARDIS which opens.
Inside the TARDIS is a bright light in the middle of the room which after a talk, Dr. Simeon walks into the light. Dr. Simeon disappears and clones of his is spread throughout history. The battles that the Doctor had won begin unravelling and the stars go out and some of the Paternoster Gang begin to disappear. Clara says she can fix it and walks into the light in the same way Dr. Simeon did.
The same montage of clips that we saw at the beginning of the episode is repeated with a few new ones. Clara lands on the ground and the Doctor tells her to get up. Once up, Clara sees the previous incarnations of the Doctor but there's one new one, the War Doctor played by John Hurt.