The TARDIS cloister bell is ringing, which means danger. The Doctor wants to stay out of trouble this time and work on the broken chameleon circuit, so the TARDIS can take on the proper protective coloration when it lands somewhere. He materializes around a real police box on Earth, so he and Adric can make some exact measurements and the mathematicians on the planet Logopolis can do the proper block transfer computations.
The Master materializes his TARDIS around the police-box first, creating a recursion loop. Stepping outside, the Doctor sees a figure in white—the Watcher—directing him to Logopolis immediately. He reappears several times. On the way to Logopolis, the Doctor and Adric find that an Australian stewardess named Tegan Jovanka (Janet Fielding), is on board. Her car broke down on the way to Heathrow Airport and she went into a police-box to call for help. She was lost inside for what seems like hours and demands to be returned. Later, she learns that the Master killed her Aunt Vanessa.
At Logopolis, the Doctor gives the measurements to the Monitor (John Fraser), the head mathematician. But it seems the Master has arrived as well and uses his tissue-compression eliminator to kill several mathematicians. Nyssa (Sarah Sutton) from Traken is under his control, and they use a device to silence the rest of the mathematicians. He demands that the Monitor explain the purpose of the radio telescope on the planet, which is instrumental in keeping the fabric of N-space from coming apart.
They find that the planet is turning to dust beneath them. The calculations of the mathematicians were to power charged vacuum embointments so they could funnel excess entropy out of this universe to prevent its approaching heat death. They have been keeping the cosmos stable for some time, but thanks to the Master messing about, entropy is taking over. The Doctor and the Master agree to work together. It’s worked so well before. Nyssa is released and they bring Tegan to Earth in the Master’s TARDIS. Adric and Nyssa try to follow in the Doctor’s TARDIS, but end up outside the universe, watching entropy obliterate Nyssa’s home planetary system, the Traken Union. They fix the controls and follow to Earth.
On Earth, the Doctor and the Master use the radio telescope of the Pharos Project to send the program fix, while the Doctor’s companions keep the guards away. But the Master broadcasts a message, blackmailing the rest of the universe. Submit to him or be destroyed. The Doctor climbs out on the telescope to stop the broadcast and send the program fix. Foiled again, the Master escapes in his TARDIS. The Doctor falls off the telescope and his companions gather around him. As he dies of his injuries, the Watcher appears and approaches. He touches and merges with the Doctor, causing him to regenerate as the Fifth Doctor (Peter Davison).
On Logopolis, they use a hexadecimal number system, based on sixteen. The police box the TARDIS materializes around was a real one—though out of commission—located at the Barnet Bypass, just about the last such box in existence in Britain. This kind of ties into the big themes of the story—the Doctor genuinely misses Romana, the TARDIS is getting old, the Doctor is getting tired, and the universe is succumbing to entropy. There have been complaints about the story—notably the fact that the death of the most long-lasting and arguably best Doctor is kind of underwhelming. Battling the greatest criminal mastermind of all Time, whose threat, despite the appalling loss of life, is little more than a dumb mistake, the Doctor saves the universe, as he does, but dies falling off a tower. But then, death is seldom as grand and noble as it is pictured in literature. Let’s face it: there are only three ways to die: decrepitude, murder or suicide, and a stupid mistake. All of these are tragic, but it is those of us who are left to mourn who give death meaning by what we do afterwards.