[[caption-width-right:344:The Fourth Doctor meets a ghost from his future and realises his time is short before he hangs up the scarf and switches to celery.]]
->''"Never guess. Unless you have to. There's enough uncertainty in the universe as it is."''
-->-- '''The Doctor'''

The universe nearly ends and Tom Baker leaves ''Doctor Who''. We're not sure which is more important at this stage.

The Doctor and Adric make a pit stop in 1981 Britain, so that the Doctor can materialize right on top of a real police box and make hyper-precise multi-dimensional measurements of it, which he needs to take to the mathematics nerds of Logopolis so they can fix the chameleon circuit. ([[{{ItMakesSenseInContext}} Just nod along, OK?]]) The Master, anticipating this, materialises his spare TARDIS (which [[Recap/DoctorWhoS14E3TheDeadlyAssassin he nicked from Goth that one time]]) around that exact same police box moments before. Which means that the Doctor's TARDIS now contains the Master's TARDIS containing a real police box. (Still following us?) Time and space get a bit wonky, so the Doctor and Adric investigate the string of [=TARDISes=] in the console room -- all identical except for being [[EvilIsNotWellLit progressively less well-lit]].

Meanwhile, a plucky young Aussie named Tegan Jovanka is off to her first day of work as a flight attendant, when TheAllegedCar breaks down on the way to Heathrow. Good thing there's a handy police box nearby, so she can call for help. But she hadn't planned on getting ''lost inside''. She completely fails to be impressed by the fact that it's obviously an alien spaceship, and instead decides to go yell at the captain of the thing. Meanwhile, her aunt, who was driving her to the airport, has been murdered by the Master for no real reason.

The sonorous ''bong'' of the TARDIS's cloister bell (its OhCrap signal) makes itself heard, so the Doctor and Adric eventually find their way through the nesting [=TARDISes=] back to the outside world. The Doctor suspects that the multiple [=TARDISes=] thing is yet another devious trick of the Master, and dematerializes at once, bound for Logopolis. Tegan, by now extremely confused, finds her way back to the control room and demands to know what the hell is going on and to be put back in 1981 ''right now'', please -- rather angrily, true, but then again "Sorry I'm late, I accidentally stepped into a spacetimeship that looked exactly like a police box and ended up traveling the universe in the company of an alien with an enormous scarf and a swotty maths geek from another dimension" is, as excuses go, pretty lousy. Especially for one's first day on the job.

And while all that is happening, a white figure quietly watches. The Doctor goes to have a word with it eventually, and comes back in an extremely gloomy mood, telling Adric to prepare for the worst.

The TARDIS soon materializes on the dusty, cave-pocked planet of Logopolis, home of the maths monks. It is, we learn, an enormous analogue of a computer. A task is broken down into a series of calculations; each monk performs a single calculation and passes the result on to the next monk over. Operations are overseen by the Monitor (get it?) in a sort of large workroom. After reuniting with Nyssa, who is deposited on the planet by the mysterious white Watcher, the TARDIS crew finds the Monitor. He explains that the universe is actually well past its sell-by date, and is kept from flying apart into chaos only by the power of their mighty minds, as they use their "block transfer computations" to keep the universe together.

Of course, it's time for the Master to show up and start mucking about with things. He starts small, with such pranks as shrinking the TARDIS (with the Doctor inside) and throwing a [[SpannerInTheWorks spanner into the endless work of Logopolis]]. Unfortunately, Logopolis can't be restarted once it's stopped, resulting in a rather ''large'' problem for those who still want to, you know, ''exist''. The Master hadn't really counted on accidentally deleting much of the universe. And while Tegan and Nyssa are both horrified at even having to be near him (Nyssa, of course, especially because he nicked her father's body), the Doctor reluctantly agrees to try and help the Master fix the spreading entropy.

The Doctor tells Adric, Nyssa, and Tegan to enter the TARDIS, which he has arranged for the Watcher to pilot out of time and space so they will be safe. Tegan, however, still thinks the Doctor is the best bet for getting home and decides to disobey his order and follows him and the Master as they go to speak to the Monitor. The Monitor reveals to the two that there is a backup plan that might be able to save everything. The people had been completing a program that could automatize its operation, but before the Monitor can boot up the program, him and the computer equipment is swallowed by the entropy field. For a moment all seems lost, but the Doctor, however, realizes that they still have a chance; Logopolis' computer equipment was an exact copy of the Pharos Project, a giant radio telescope on Earth. The Doctor, the Master, and Tegan then escape from the disintegrating Logopolis in the Master's TARDIS, setting a course for Earth.

Adric and Nyssa, meanwhile, can only watch helplessly, as the encroaching entropy wipes out a potion of the universe. Much to Nyssa's despair it includes Traken.

Landing inside Pharos Project, the Master and the Doctor eventually manage in cooperation to install the backup system and restore balance to the universe. But true to form, the Master decides to double-cross the Doctor; he uses the radio telescope broadcast to a message to all intelligent life in the universe: they must submit to him or else he will knock out the backup system and unleash the entropy field upon everything again.

After a chat with the Watcher inside the deepest parts of the TARDIS, Adric is able to follow the Doctor, and the ducklings cause enough of a distraction to allow the Doctor to muck up the Master's plans. Fortunately, this leaves the larger part of the universe intact. Unfortunately, the Master and the Doctor break out into a fight on top of the Pharos Tower. The Doctor sees visions of his worst enemies attempting to kill him. Clashing on the gantry, the two Time Lords wrestle to the floor. The Master gets up first and bolts to the controls of the telescope. He tilts the radar dish until the gantry completely flips over. Grabbing a cable and desperately trying to hang on to it, the Doctor sees several visions of his various enemies taunting him. Gradually, his strength begins to fail him, and finally his grasp slips, causing him to fall. The cowardly Master runs away sniggering in his TARDIS after this cheap act of murder.

Dying, the Doctor has several soothing flashes back to his previous companions in that incarnation. The next thing he knows, he's surrounded by the trio of current companions who are quite worried about him, snapping him out of the daze. The Fourth Doctor simply gives them a serene glance and tells the group with an assuring smile, "It's the end... but the moment has been prepared for."

The Watcher approaches and merges into his dead body, and turns out to have been a time/space-transcending echo of his next incarnation all along. The Doctor [[TheNthDoctor regenerates]] into a young blonde gentleman, who greets everyone with a smile. The [[Creator/PeterDavison Fifth Doctor]] starts his first day almost drowning in the sheer amount of coat and scarf he's wearing, not to mention chased by some very angry security guards.

* AMillionIsAStatistic: The story involves the destruction of one quarter of the entire universe; by even the most conservative estimates that's a single-episode death toll expressible only in standard notation. And not only does nobody seem to care (including one character whose home ''intergalactic supercluster'' was destroyed [[note]] He also killed her Dad [[/note]]), the villain responsible gets the full DracoInLeatherPants treatment despite being possibly the worst mass-murderer in all fiction (but in all fairness, it was an accident)!
* AdaptationExpansion: In the novelisation, the Doctor receives a message from Traken about Tremas while Adric is occupied reading ''Literature/ParadiseLost''.
** The Master's TCE stinks of ozone.
** The Watcher is expanded upon.
* AllThereInTheManual: The policeman using the telephone in the police box in the opening scene of the story is named in Christopher H. Bidmead's novelisation as P.C. Donald Segrave. This was not derived from any information given in the televised version.
* ArtisticLicensePhysics: Though the description of how the heat death of the universe would work is basically correct, the way it's depicted bears no resemblance whatsoever to the actual theory, and in fact is more similar to the "Big Rip" theory.
** According to the expanded verse story (The Invasion of E-Space), CVE is (in that verse) the rarest of space-time events and almost undetectable, entities containing layers of highly charged quantum particles suspended in pockets of super-vacuums. They occupied the space between realities (possibly the void) and were so violent in their physics that when they formed they punched a hole between universes, pushing space aside to insinuate themselves into reality, releasing massive waves of energy in the process. (And since heat death means no more energy, the way they do so brings forth new energies to both universes.)
* BlackmailIsSuchAnUglyWord: As the Master announces his threat to destroy the universe unless its people submits to him:
-->'''The Doctor''' ''(outraged)'' Blackmail!\\
'''The Master:''' No, Doctor, I'm merely reporting the state of affairs.
* CallBack: It's revealed that the CVE the TARDIS fell through earlier in the season was actually one of many created by Logopolis to let the entropy drain away and prevent the universe from collapsing.
** The Watcher's role in events may be a CallBack to Cho Je from "Planet of the Spiders", thus [[BookEnds linking the Fourth Doctor's origin-story to his finale]].
* DidntSeeThatComing: Oops. The Master didn't actually ''intend'' to destroy so much of the universe... including Nyssa's homeworld.
* [[DroppedABridgeOnHim Dropped Him Off A Radio Tower]]: What causes the Doctor's regeneration.
* EndOfAnEra: Creator/TomBaker's seven year run comes to an end.
* EnemyMine: The Doctor and the Master must work together to save all of existence.
* EstablishingCharacterMoment: When Tegan gets lost inside the TARDIS, instead of being astonished by it, she goes and looks for someone to yell at.
* EvilHand: Nyssa's bracelet.
* FaceDeathWithDignity: The Fourth Doctor is fully prepared for his death and accepts it with a smile.
* FamousLastWords: "It's the end... but the moment has been prepared for..."
* FinaleCredits: Since Part 4 is Creator/TomBaker's swan song, his face is visible during the ClosingCredits for only the briefest of moments.
* {{Foreshadowing}}: The novelization of this serial gives an early clue as to who the Watcher is. When the Doctor sends Adric and Nyssa away from Logopolis, he entrusts them to the Watcher. Aboard the TARDIS, the Watcher silently summons Adric alone and apparently has a dialogue with him. Afterward, Adric claims that although he remembers the Watcher's instructions, he can't quite remember what the Watcher's voice sounded like except that it sounded familiar.
* GoodWithNumbers: Logopolis is this trope in ''city form''.
* GoOutWithASmile: We get one last glimpse of Creator/TomBaker's big toothy smile before the regeneration.
* GrandFinale: For Creator/TomBaker's era as The Doctor.
* FloatingAdviceReminder: Happens twice in Part 4. The first time, while hanging on the Pharos Project's power cable, the Doctor is taunted by visions of [[Recap/DoctorWhoS14E3TheDeadlyAssassin the (decayed) Master]], a [[Recap/DoctorWhoS17E1DestinyOfTheDaleks Dalek]], the [[Recap/DoctorWhoS16E2ThePiratePlanet Pirate Captain]], the [[Recap/DoctorWhoS12E5RevengeOfTheCybermen Cyberleader]], [[Recap/DoctorWhoS12E4GenesisOfTheDaleks Davros]], a [[Recap/DoctorWhoS15E6TheInvasionOfTime Sontaran]], a [[Recap/DoctorWhoS13E1TerrorOfTheZygons Zygon]], and the [[Recap/DoctorWhoS16E6TheArmageddonFactor Black Guardian]]. Then after falling, the Doctor sees visions of his past companions from Sarah Jane to Romana II.
* HeroicSacrifice: The Doctor. Actually a realistic one, as his death isn't a direct cause of saving the day, but because he pulls off an incredibly risky stunt that he doesn't recover from.
* TheMaster
* MikeNelsonDestroyerOfWorlds: The Master inadvertently manages to unleash great destruction upon about '''a ''quarter'' of the Universe''', simply because he didn't fully understand the danger of interfering with Logopolis' operations. It is without a doubt the greatest atrocity he has ever committed on the show, if not the single greatest atrocity ''ever'' depicted on the show, and he basically did it by pure accident.
* MyBrainIsBig: The inhabitants of Logopolis.
* MysteriousWatcher: The Watcher
* OhCrap: The Master, when he realises the Doctor is going to disconnect the cable at the radio telescope.
* PlanetOfHats: Their hat is genius, universe-maintaining mathematicians.
* RealityWarping: The Logopolitans are seemingly capable of arbitrary reality warping by meditating on the equations that physically describe the universe, or objects within it.
* ShootTheShaggyDog: A significant proportion of [[spoiler:the ''entire universe'']] is [[spoiler:destroyed by entropy]]. Although insignificant on the scale of such an unbelievably cataclysmic event, the region destroyed includes [[spoiler:the Traken Union]], thereby almost immediately rendering all the events, people and struggles in [[spoiler:''[[Recap/DoctorWhoS18E6TheKeeperOfTraken The Keeper of Traken]]'' (the previous connected story)]] dramatically null, void and pointless. (The fact that this is only obvious when you [[FridgeLogic stop and consider it]] suggests that this was a side-effect rather than dramatic intent on the part of the writers).
* ShownTheirWork: Writer Christopher H. Bidmead seems to have done more reading up on computers than on entropy. The monks of Logopolis work and communicate in hexadecimal (base 16), just like real computers. At one point, the Doctor mentions "bubble memory"--which is real, and was the subject of a lot of research in 1981.
* SpannerInTheWorks: The Master doesn't actually ''plan'' on wiping out part of the universe or destroying Logopolis. See also: GoneHorriblyRight.
* TheStarsAreGoingOut: the entropy spreads and consumes part of the universe.
* TheWatcher: Played straight with The Watcher, who watched the Doctor and his companions throughout the serial, and was revealed to be a manifestation of the Fourth Doctor, which Foreshadows his regeneration into the Fifth Doctor.
* ThemeSongReveal: The Watcher's ominous theme during his appearances. This is before the audience is let in on what he really is (although the Doctor obviously knows but isn't telling). However, in the final scene of the story, when the Watcher's true nature is revealed to everyone, the full course of the piece plays out with the last three notes being the first three notes of the Doctor Who theme song.
* WetwareCPU
* WhamEpisode: Creator/TomBaker was the most popular Doctor the classic series ever had, so his departure after seven seasons into the (then) youngest Doctor actor ever was a Wham.
* XanatosSpeedChess: The Master's magnificent comeback from ''accidentally'' destroying about a quarter of the universe to holding the rest to ransom
* YoureInsane: Before their final confrontation, as The Master reveals his endgame, the Doctor utters with dread:
-->'''Doctor''': You're ''mad''...you're ''utterly mad!''