The Inquisitor brings in the Keeper of the matrix and asks if The Doctor is done with his defense. The Valeyard reminds them of the charge of genocide. The Doctor says much of The Railyard's evidence has been distorted. The matrix was tampered with. The Keeper says it is impossible to change, only he holds the key of Rassilon needed to enter the matrix. The Doctor points out the key does get used, could be copied, and it COULD be distorted. The Valeyard says there is no evidence. When asked who would do this, The Doctor blames The Valeyard. Another shot outside the ship, with the beam of light appearing, this time bringing in two oddly casket shaped capsules. Inside The Doctor is saying he can only rebut evidence with witnesses, which he doesn't have. In walk Mel and Glitz, to The Doctors confusion. They say they were sent, and a face appears on the matrix screen. The Master. He's inside the matrix.
This is proof the matrix can be invaded. The Master has a copy of the key. The Inquisitor is upset. The Master claims to be intervening in the name of justice, which makes The Doctor laugh. The Master doesn't like The Valeyard. The Valeyard objects and pretends not to know him. The Master has sent Mel and Glitz. The Valeyard calls Glitz a criminal, but The Inquisitor allows the witness. The Doctor questions Glitz about the secrets he was after. Glitz reveals that the sleepers had found a way into the matrix. They were operating from Earth and the Timelords found out. The Timelords used a magnatron, which must be ordered by high counsel, to move the Earth, renaming it Ravalox. This caused the fireball and the rescue team from Andromeda to never find the sleepers, thus the secrets. The Doctor says he has had many enemies, but he should have stayed on Gallifrey, calling them corrupt. It would have remained secret if The Doctor hadn't gone to Ravalox. The Master says the high counsel struck a deal with The Valeyard, or as he's always known him, The Doctor, to distort evidence and make The Doctor a scapegoat, promising The Valeyard the rest of his lives. The Valeyard is an amalgamation of the darker sides of The Doctor's personality, somewhere between his 12th and final incarnation. The Doctor objects at both prosecution and defense being the same person. The Inquisitor says in this case it is irrelevant. But The Valeyard runs. They follow but just outside he has disappeared. The keeper says he must have gone through the 7th door and opens it for The Doctor, who takes Glitz with him into the matrix.
A beam of light brings The Doctor into the streets and back alleys of what appears to be Victorian times maybe? It's dark, there's hay, you hear horses clopping, there are rats, no people around, but a man's laughter. No Glitz, either. Children in the distance hauntingly sing London Bridge. Then there's a saloon piano playing somewhere. The Doctor finds a barrel and looks into the water. Hands reach out and pull his face under. Glitz appears, but The Doctor is on the ground awake. He says in the matrix the only logic is there is no logic. Nothing is real. Glitz hands The Doctor a note from The Master with the location of The Valeyard's base. It's called The Fantasy Factory, and the proprietor is J.J. Chambers. Why is The Master helping? In the courtroom The Master is filling in The Inquisitor and tells her The Valeyard exploited The Doctor's feelings for Peri, who was actually still alive, the Queen to King Yrcanos. The Valeyard is playing games with The Doctor and Glitz. The Master hopes The Doctor and Valeyard destroy each other. The Doctor and Glitz go inside the factory. Junior Mr. Popplewick asks if they have an appointment and talks about procedures and things taking time. The Doctor rushes through the office door to find the same man, except the senior Mr. Popplewick this time. More procedure and appointment talk. He asks The Doctor to sign a release so that if he dies while there, Mr. Chambers gets his remaining lives. The Doctor signs. The Doctor enters the waiting room to find himself on a beach alone. He hears laughter as hands grab his ankles from under the muddy sand. The Doctor falls and the hands pull him under as he screams.
Glitz arrives, but not in time, The Doctor goes under. But he rises up dry and reminds Glitz they aren't dealing with reality. The Valeyard appears, and keeps popping around the place while he talks. The Doctor asks why he wants him dead. The Valeyard says to be free of The Doctor's morality, and with unlimited access to the matrix nothing would be out of his reach. He disappears. A fog starts coming in, nerve gas. The Doctor and Glitz run. Mel is in court watching this on the matrix screen. The Inquisitor says they can't interfere. Mel wants the key to the 7th door but doesn't get it. The Doctor helps Glitx into an old rundown house, which dematerializes. They are inside The Master's TARDIS. The Master wants The Valeyard eliminated. He sets his console and takes Glitz out of the room. Loud noise and lights start flashing and The Doctor is forced into a catatonic state. The Master's TARDIS materializes as an old tomb in front of the factory. The Master brings out The Doctor and stands him there. He and Glitz hide as his TARDIS dematerializes. The Valeyard comes out and The Master tries to shoot him, to The Valeyard's amusement. He sends little explosions after The Master as he and Glitz run.
The Doctor reacts when he hears Mel's voice. She's calling from the shadows and gets him to come with her. They exit the 7th door and she says he must clear his name. The Inquisitor wants an apology and he gives her one. The charge of genocide is still before them. After assuring them he would trust Mel with his life, they show her the clip of destroying the Vervoids. The Doctor says tell the truth and she admits The Doctor acted on his own, there was no choice. She senses something is going wrong. The Doctor admits you always have a choice. The Inquisitor delivers a verdict of guilty, saying his lives are forfeit. The Doctor accepts the sentence. Mel and the real Timelords are watching this on the matrix screen. Mel is upset he is being tricked and finally gets the key from the keeper. Inside the matrix she sees The Doctor standing stoically in a horse drawn cart led by a Gallifreyan guard. Mel tries to save him. He whispers for her to go away. But the damage is done, the cart and horse disappear. Mel ruined it. The Doctor was trying to force a confrontation with The Valeyard. When fake Mel gave evidence of The Doctor denying the genocide charge he knew she hadn't even been there at the time. The Master wants Glitz to lead The Doctor to The Valeyard and tries to hypnotize him. Glitz is all money, though, so The Master offers him a chest full of treasure.
The Doctor is searching one office and in another Glitz finds the tape of secrets, the original copy. He also finds the senior Mr. Popplewick. The Doctor finds a list of the Timelords at his trial, all crossed out, and in his handwriting. Glitz comes in with Popplewick, who will take them to Chambers. Glitz leaves with his tape of secrets but The Master forces him to his TARDIS. Popplewick keeps stalling, but The Doctor knows what's what and takes the mask off Popplewick to reveal The Valeyard. Mel opens some doors marked danger and claims there is a megabyte modem, which sounds ridiculous now but at the time was so fancy sounding. The Doctor calls it a MASER, or microwave amplification and stimulated emission of radiation. The Doctor processes the info. It is a particle disseminator, which will destroy everything. The Valeyard is untying himself. The Doctor gets the list of names, it is a hit list. They must disconnect the matrix and evacuate the courtroom.
In the courtroom The Inquisitor learns the high counsel has been deposed, there is chaos. The Master, on the screen, is pleased and offers his leadership. In his TARDIS he plugs the tape into his console, but everything gets distorted and he and Glitz are trapped against the wall unable to move. Mel bursts into the courtroom and yells to get out. They don't, the screen explodes, but everyone is fine. The Doctor had fiddled with the maser, but he also triggered a feedback. The Doctor runs, but The Valeyard stays and is apparently killed when we see the building explode. The Doctor appears in the courtroom asking about his sentence. The Inquisitor gladly tells him all charges are dropped, and let's him know that Peri is still alive. They show a sweet shot of Peri and Yrcanos from "Mindwarp." The Inquisitor tries to persuade The Doctor to run for Lord President again, but he suggests she take up the post. He asks her to be lenient on Glitz when they restore the matrix. The Doctor and Mel stand outside the TARDIS and she talks about getting back to exercise and carrot juice. They leave, which makes me wonder. When did the Master take Mel and bring her? The Doctor was taken when he was with Peri, so he has not traveled with her yet but she has with him! That one is definitely a first, and is partially what happens with River Song.
Back in the courtroom the Timelords are leaving. The Inquisitor instructs the keeper to reconstruct the matrix as she leaves. The Keeper turns around and it is The Valeyard.