The TARDIS crew arrive in Mexico in the 15th Century. With the TARDIS trapped in a tomb, Barbara is mistaken for a female reincarnation of the ancient high priest Yetaxa, and assumes her guise and identity. In her new position of power Barbara sees her chance to bring an end to human sacrifice. She sees the good side of Aztec culture manifested in Autloc, the High Priest of Knowledge, and the gruesome side embodied in 'the local butcher' High Priest of Sacrifice, Tlotoxl. As somewhat of an expert on this period, she sees how advanced their culture really is and believes that if sacrifice were abolished, they would be spared destruction at the hands of the Spanish. The Doctor's urgent warnings that Barbara cannot change history fall on deaf ears, much to the Doctor's fury.
The bloodthirsty Tlotoxl begins to suspect Barbara is not Yetaxa returned, especially because she is trying to ban human sacrifice. He sets a series of elaborate traps for her and her companions. For example, Ian has been compelled into the military and fights the strongest warrior, Ixta, to prove his ability to command the Aztec forces. Thus Ixta develops a grudge against Ian and is used by Tlotoxl to try and prove Barbara is not Yetaxa. The Doctor unwittingly tells Ixta how to defeat Ian in combat using a drugging agent, and this battle nearly ends in the Doctor witnessing his friend's death. When this fails to be conclusive, Tlotoxl convinces the sobordinate priest Tonila to make a poison for Barbara; the death of Barbara following consumption of the poison would prove she is not immortal and therefore not a god. But Ian silently warns her from his hiding place, and Barbara refuses to drink the poison. She tells Tlotoxl that she is not Yetaxa but warns him not to tell the people. He now knows the truth - but must find a way to unmask the false goddess.
Susan and the Doctor have meanwhile both become involved in marriage-making scenarios. Susan has transgressed Aztec law by refusing to marry the Perfect Victim, who has been scheduled for sacrifice by Tlotoxl on the day of the next eclipse; while the Doctor, who knows little of Aztec customs, has become accidentally engaged to an Aztec woman named Cameca after they shared a cup of cocoa. Cameca is a kind lady and helps the Doctor and Ian find a way to re-enter the tomb by a secret entrance, despite realizing this will help her beloved leave her. Ian braves a treacherous tunnel in which he is almost drowned to re-enter the tomb by a secret door and soon tells his friends that they can flee.
Despite her efforts Barbara realizes she cannot change an entire culture, although she does succeed in changing the views of one man, the High-Priest of Knowledge, Autloc, although this comes at a high price to Autloc, who exiles himself. He helps her become reunited with her friends before departing to meditate in the desert on what remains of his faith. In a pitched battle to gain access to the tomb door, Ian kills Ixta in a fight to the death, as shown in the picture, to protect the TARDIS crew.
The Doctor and his companions leave knowing that despite their intervention, history will take its pre-destined course. As they depart Tlotoxl is very much in control and sacrifices the Perfect Victim to end the naturally occurring eclipse. The Doctor comforts Barbara by telling her she did help Autloc find a better belief system; and then before they depart he re-pockets a brooch given to him as a parting gift by Cameca.