On the planet Tigella, deep beneath the surface, a conflict of sorts is going on between the Savants (the science class) and the Deons (the religious class). The conflict is centered around the mysterious Dodecahedron, an object that provides all the power to run their planet.

To the Savants the Dodecahedron is a miracle of science to be studied, observed and used to benefit Tigellan civilization. To the Deons it is a god and not to be tampered with.

When the power supply begins to fluctuate wildly the whole planet is threatened, but the Tigellans cannot agree how they should deal with the problem. Zastor, the leader of Tigella, suggests inviting the Doctor to help them with their problem. Zastor has had experience with the Doctor before and trusts his wisdom. The Deons are not so trusting, however, and question bringing in a Time Lord.

Meanwhile, a ship of mercenaries arrives on the desert surface of a planet. They have been hired to deliver an unfortunate human to what turns out to be an intelligent cactus named Meglos. Meglos appears to have plans, the first of which is to transport his consciousness into that of the human. Now ambulatory, Meglos proceeds to interfere with the Doctor's imminent arrival on Tigella.

Aboard the TARDIS, the Doctor and Romana are making repairs to K-9. Just as they have nearly completed the repair, they find themselves reliving the proceeding moment over again. It seems they have been stuck in a time loop, one which they may never get out of.

While the Time Lords are occupied with this problem, Meglos has decided to take on the Doctor's appearance and take his place on Tigella. Meglos and his mercenaries land on Tigella, and Meglos is quickly greeted by the Tigellans and taken to the city below the surface.

Meglos asks to be taken to the Dodecahedron, but he is required to take an oath of allegiance to Tigh first. He does so with out much question, then demands to be allowed to proceed into the dodecahedron chamber alone. Once in the chamber, Meglos grabs the dodecahedron and exits quickly.

Back on the TARDIS, the Doctor has figured out how to escape the time loop, and continues on his journey to Tigella. He arrives on the surface of the planet with no idea of what has been occurring. On their way to city, the Doctor is separated from Romana who lags behind to study some burnt fauna. Unfortunately, some of those plants attack Romana, and she is barley able to escape from their tendrils. She does, however, also discover the mercenaries ship, but then is also discovered by those same mercenaries.

The Doctor arrives at the city gates just as the Tigellans have begun to realize their power source has been stolen. Of course their number one suspect is the Doctor, and the real Doctor is quickly grabbed and brought before the Tigellan leaders.

Romana uses confusing logic to outsmart the mercenaries and lead them back to the very plants that attacked her earlier. Using the distraction, Romana is able to escape their grasp and slip into the city.

Meanwhile, a decidedly prickly Meglos is trying to escape the city unnoticed, but a lone Tigellan stumbles upon him and captures him at gunpoint. Unfortunately, Romana, seeing the Doctor being held hostage, hits the Tigellan from behind, mistakenly allowing Meglos to escape. Meglos reaches his mercenaries and boards his ship carrying with him the dodecahedron.

With the confusion inside the city, the Deons have decided to take control and imprison all non-believers. Not only that, but they feel that sacrificing the Doctor is necessary to appease their god. Somehow his death will restore the dodecahedron. Romana races to stop the sacrifice just in time.

The Doctor realizes that Meglos plans to take the dodecahedron back to his own dead planet where it can be used to power a device capable of destroying planets. The first victim is unfrotunately Tigella.

The Doctor decides to use Meglos's own plan against him and impersonate Meglos impersonating the Doctor in order to infiltrate past the mercenaries. Confusion ensues as the mercenaries double cross Meglos and eventually throw both he and the Doctor into a locked room. The Doctor finally comes face to face with Meglos.

Romana rescues the Doctor from the locked room. Meglos escapes by leaving his human host and returning to his cactus form. It doesn't do him much good, because the Doctor has turned the dodecahedron device from Tigella and pointed it at the planet they are on. Meglos dies in a massive explosion as the Doctor and Romana escape in the TARDIS