In Egypt in 1911, Marcus Scarman excavates a pyramid and finds that the door to the burial chamber is inscribed with the Eye of Horus. Scarman's Egyptian assistants panic and flee, leaving the Professor to enter the chamber alone. As he holds a light up to see the undisturbed tomb, he is blasted by a green ray.

The TARDIS is forced out of its flight path and Sarah sees an apparition of a jackal-like face in the console room. The Doctor lands the TARDIS in the Scarman family home in England, which is filled with Egyptian artefacts. Discovered by the butler, they are told that the house has been taken over by a mysterious Egyptian by the name of Ibrahim Namin. In another part of the priory, Namin is confronted by Dr. Warlock, a friend of Professor Scarman. The Doctor, Sarah and Warlock make their escape into the grounds of the estate. Instead of following, Namin commands a mummy to pursue them. The three make their way to a hunting lodge used by Laurence Scarman, Professor Scarman's brother. Laurence is an amateur scientist whose marconiscope has intercepted a signal from Mars. The Doctor decodes the signal as "Beware Sutekh". He explains that Sutekh is the last of a powerful alien race called the Osirians. He was pursued across the galaxy by his brother Horus, and was finally defeated on Earth.

Namin and the mummies — really service robots — greet the arrival of Sutekh's servant who travels to the priory via a spacetime tunnel, the portal of which is disguised as an upright sarcophagus - Namin originally thinks Sutekh has arrived, but the servant tells him to look up and then says "Is this the face of Sutekh?". Namin begs for the Servant to spare him, saying he is a true servant of Sutekh. However, the Servant burns Namin to death, declaring that Sutekh needs no other servant and saying he brings Sutekh's gift of death to all humans. He is revealed to be Marcus Scarman. Sutekh orders him to secure the perimeter of the estate and to construct an Osirian war missile. After Scarman and the robots leave, the Doctor, Sarah and Laurence Scarman enter. The Doctor disrupts the tunnel using the TARDIS key. Hearing Scarman return, Laurence hides the three of them in a priest hole.

In another part of the estate, a poacher, Clements, finds a mummy ensnared in a man-trap. He is prevented from escaping the estate by a deflection barrier. Meanwhile, Marcus Scarman finds Warlock and kills him. The Doctor retrieves Namin's ring from his corpse and he and Sarah hide in the TARDIS to avoid detection; Sarah suggests they should just leave, because they know that the world did not end in 1911. The Doctor moves the TARDIS forward to 1980, where it is a blasted wilderness. They have no choice but to return to 1911 and stop Sutekh or the future will be lost.

Back in 1911 the Doctor makes a jamming unit, telling Sarah that when it is activated, all of Sutekh's servants will stop, Marcus Scarman included. Laurence attempts to stop the Doctor from activating the device. The robots find and kill Clements and overrun the hunting lodge. Sarah, using the ring they took from Namin, orders the robots to return to Control.

The Doctor decides to blow up the partially assembled rocket in the stable courtyard of the priory. Laurence suggests using blasting gelignite, which Clements kept in his hut. The Doctor and Sarah leave to obtain the gelignite, ordering Laurence to strip the bindings from a deactivated robot. The Doctor unlocks the energy barrier, allowing them to pass through. Sutekh orders Marcus Scarman to investigate. Marcus finds Laurence, who reminds his brother of their childhood in order to revive his humanity. The conditioning proves too strong, and Marcus kills Laurence.

The Doctor and Sarah detonate the explosives, but Sutekh telepathically suppresses the explosion. The Doctor uses the spacetime tunnel to travel to and distract Sutekh, allowing the rocket to be destroyed but trapping himself. Sutekh interrogates the Doctor and discovers he is a Time Lord from Gallifrey. He locates the TARDIS and decides to use it to transport Scarman to Mars in order to deactivate the Eye of Horus, which is holding him prisoner. Sutekh subjects the Doctor to mind control and returns him to the priory. He orders Scarman to bring a robot and Sarah into the TARDIS to travel to the pyramid of Mars.

On their arrival, Sutekh orders Scarman to dispose of the Doctor and the robot strangles him. Scarman leaves the first chamber beneath the pyramid and the Doctor regains consciousness, his respiratory bypass system having allowed him to avoid death. They set off in search of Scarman through a series of chambers which are dependent upon solving logical and philosophical problems.

Reaching the central chamber first, Scarman destroys the Eye before falling to the floor and decaying to dust. Arriving too late, the Doctor realises that Sutekh will not be released for two minutes, that being the time that radio signals take to travel from Mars to Earth. Sarah and the Doctor return to the Priory. Sutekh begins his journey from Egypt through the time tunnel; but the Doctor uses a module from the TARDIS to move the other end of the tunnel to a point 10,000 years in the future, ensuring Sutekh will not escape until he dies of old age. The Doctor and Sarah leave in the TARDIS as the priory is consumed in flames.

Sarah wears a dress which the Doctor says belonged to Victoria.[1] She remarks that the puzzles are similar to those in the Exxilon City in Death to the Daleks, although she personally never entered the City.[1]

The story as originally written by Lewis Greifer was considered unworkable. As Greifer was unavailable to do rewrites, the scripts were completely rewritten by Robert Holmes. The pseudonym used on transmission was Stephen Harris. Pyramids of Mars contributes to one of the contradictions in the Doctor Who universe: the UNIT dating controversy.

The exterior scenes were shot on the Stargroves estate in Hampshire, which was owned by Mick Jagger at the time. The same location would be used during the filming of Image of the Fendahl. The new TARDIS console, which debuted in the preceding story Planet of Evil, does not appear again until The Invisible Enemy. Owing to the cost of setting up the TARDIS console room for the filming of only a handful of scenes, a new console set was designed for the following season. Tom Baker and Elisabeth Sladen improvised a number of moments in this story, most notably a scene in Part Four where the Doctor and Sarah start to walk out of their hiding place and then when they see a mummy, quickly dart back into it. Baker based the scene on a Marx Brothers routine.

Several scenes were deleted from the final broadcast. A model shot of the TARDIS landing in the landscape of a barren, alternative 1980 Earth was to be used in Part Two, but director Paddy Russell decided viewers would feel more impact if the first scene of the new Earth was Sarah's reaction as the TARDIS doors opened. Three scenes of effects such as doors opening and the Doctor materializing from the sarcophagus were removed from the final edit of Part Four because Russell felt the mixes were not good enough. These scenes were included on the DVD, along with an alternate version of the poacher being hunted down in Part Two, and a full version of the Osirian rocket explosion.

Paul Cornell, Martin Day, and Keith Topping gave the serial a positive review in The Discontinuity Guide (1995), praising the "chilling" adversary and some of the conversations.[1] In The Television Companion (1998), David J. Howe and Stephen James Walker described the first episode as "an excellent scene-setter" and the story as "near-flawless". They wrote that Pyramids of Mars gave the "fullest expression" of the Gothic horror era and had high production values and a good guest cast.[2] In 2010, Patrick Mulkern of Radio Times called it "a bona fide classic" with "arguably the most polished production to date", and praised the powerful plot. However, he disliked how UNIT was dismissed in the season, and found "minor, amusing quibbles" with the plot.[5]Charlie Jane Anders of io9 described Pyramids of Mars as "just a lovely, solid adventure story", highlighting the way the Doctor seemed outmatched, the pace, and Sarah Jane.[6] In a 2010 article, Anders also listed the cliffhanger to the third episode — in which the Doctor is forced to confront Sutekh — as one of the greatest Doctor Who cliffhangers ever.[7] In a 2014 Doctor Who Magazine poll to determine the best Doctor Who stories of all time, readers voted Pyramids of Mars to eighth place.[8]

A novelisation of this serial, written by Terrance Dicks, was published by Target Books in December 1976. The novelisation contains a substantial prologue giving the history of Sutekh and the Osirians and features an epilogue in which a future Sarah researches the destruction of the Priory and how it was explained. An unabridged reading of the novelisation by actor Tom Baker was released on CD in August 2008 by BBC Audiobooks.

The story first came out on VHS and Betamax in an omnibus format in February 1985. It was subsequently released in episodic format in February 1994. It was released on DVD in the United Kingdom on 1 March 2004. It was also released on 31 October 2011 as an extra on The Sarah Jane Adventures Series 4 DVD and Blu-ray boxset as a tribute to Elisabeth Sladen who had died earlier in the year.[9]