The Doctor arrives at a diner in Nevada; the waitress is Clara, but she doesn't seem to recognize the Doctor. He tells her a story about what happened to him.
After arriving on Gallifrey through the confession dial, the Doctor kicks out Rassilon and takes over. Using Time Lord technology, he extracts Clara from the moment before her death and attempts to save her life, against the rules and laws of time. Needless to say, the Time Lords aren't happy.
He steals a TARDIS and runs away to the end of the universe with Clara, where they meet Ashildr. He explains that is plan is to make Clara forget their adventures, so she will be harder to track. Clara is not down with this plan. In the end, it is the Doctor who ends up forgetting Clara.
Back at the diner, he reveals that he doesn't remember Clara. He remembers that their adventures happened, but he can't remember her. Clara walks into the next room, and it is revealed that the entire diner is, in fact, the stolen TARDIS, now piloted by Ashildr.
Clara asks to go back to Gallifrey to be restored to her proper death, but decides to go "the long way around." As their TARDIS vanishes, it leaves the Doctor behind. He finds his own TARDIS waiting for him, with a new sonic scredriver and a message written on the chalkboard:
RUN YOU CLEVER BOY
AND BE A DOCTOR
As he flies off into time and space, his TARDIS passes by Ashildr's.