Many years ago, Missy is awaiting execution at the hands of the Doctor when he is interrupted by Nardole, who tells him that River Song would be very disappointed in him.
In the present, the Doctor, still suffering from blindness, sits down outside the Vault. His sonic shades receive a transmission.
To his surprise, he is met in the lecture hall by a group of priests and the pope himself. They need his help. After awkwardly collecting Bill (ruining her date), they head off to the Vatican.
There is a book in the Vatican library of heresy. Anyone who reads the translation commits suicide. It has just been translated again, and it's all happening again, and the pope begs the Doctor to investigate.
Bill and Nardole discover a room with portals to places such as the Pentagon and CERN. When they go to CERN, the scientists there all commit suicide, having read an email with the translation of the book.
Nardole realizes the truth: the world is not real. Abruptly, he dissolves.
The Doctor reaches the same realization and is attacked by an alien, though he initially escapes. Everything around them, even themselves, everything is part of a simulation, an illusion created by the alien to determine whether it can conquer Earth.
The Doctor warns the alien that he -- the Doctor -- is defending the Earth. He takes advantage of the perfect recreation of the sonic shades to send a record of everything that happened to his real-world self... and the entire episode had been the real Doctor viewing this recording.