Mr. Finch, the headmaster of Deffry Vale School, has been changing the school to improve the students' performance; his changes include free lunches with special chips. The Doctor, under the alias "John Smith", is undercover as a science teacher in the school and is intriguedby the uncommon intelligence of one of the students. His companion, Rose Tyler, is working undercover in the school's cafeteria. Both the Doctor and Rose relate the mysterious events around the school to the chips: Rose observes that the chip oil has an adverse effect on the other kitchen staff, while the Doctor notes that the chips themselves are making children more intelligent.
Mr. Finch's successes have aroused media attention — in particular, the attention of investigative journalist Sarah Jane Smith. While at first the Doctor feignsignorance (but is barely able to restrain his pleasure at seeing her again), when Sarah Jane discovers the TARDIS during the night, he is forced to admit his identity. Sarah Jane meets Rose and Mickey, with an immediate rivalry sparking between the two women. As the group searches the school, they find thirteen bat-like creatures asleep in Finch's office. Returning to Sarah Jane's car, the journalist reveals a battered, inactive K-9 Mark III, who—once repaired—identifies the chip oil as Krillitane oil. Rose, unaware that the Doctor had even had past companions, confronts him; he replies sadly that, while she can spend the rest of her life with him, he cannot spend the rest of his life with her, so he must remain aloof.
The following day, the group returns to the school to investigate further. The Doctor confronts Mr. Finch, who confirms that he and the others are Krillitanes — a composite species that takes desirable attributes of the species they conquer. He attempts to subvertthe Doctor, without success. Meanwhile, Sarah Jane and Rose, now getting on better than at their first meeting, try to unlock the programming on the school's computers; Mickey and K-9 remain in Sarah Jane's car for surveillance. With the Doctor's help, they discover that the computers — bolstered by the students' enhanced intelligence — are part of a Krillitane effort to solve the "Skasis Paradigm", a theory of everything. As the paradigm is nearly solved — which would allow the Krillitanes full control over time and space — the Krillitanes seal the school. Mr. Finch propositions the Doctor a second time, temptinghim with the ability to save the Time Lords and override human mortality. With Sarah Jane's counseling, the Doctor refuses, and they run from Mr. Finch. Mickey crashes Sarah Jane's car through the school's doors and unplugs the computers, allowing the children to flee. The Doctor leads the Krillitanes to the kitchen. Upon their arrival, K-9 detonates the chip oil container, saturatingthe Krillitanes. The Krillitanes suddenly explode, destroying the school and K-9.
At episode's end, Rose, Sarah Jane, Mickey, and the Doctor are standing in the TARDIS. Sarah Jane declines a second chance of travelling in the TARDIS. Mickey says he would like to join the TARDIS crew, a suggestion of which Sarah Jane approves. She then asks Rose to stay with the Doctor and — if she needs help — to find her. Sarah Jane then gets a chance to part properly with the Doctor, who leaves her with a brand new K-9 as a parting gift.