The Invasion of Time ( TV story ) The Invasion of Time was the sixth and final story of season 15 of " Doctor Who " . It made extensive use of the TARDIS interior and added to the mythology of Gallifrey . It featured the final appearances of Leela and K9 Mark I — although it also immediately implied that the Doctor was merely replacing K9 with a new model . Its script was a last - minute replacement , written quickly by script editor Anthony Read and producer Graham Williams when the original season - ender by David Weir was abandoned . Contemporary viewers of the programme who participated in the Doctor Who Appreciation Society ' s season 15 poll voted it the best story of the season . ( REF : " The Fourth Doctor Handbook " ) Narratively , it established that Sontaran s were a major , credible threat to the Time Lord s , carrying through on a foreshadowing reference in their first appearance in " The Time Warrior " . It laid the groundwork for future Sontaran stories , including their pursuit of time travel in " The Two Doctors " and their knowledge of Gallifrey ' s demise in " The Sontaran Stratagem " . The fact that Leela remains on Gallifrey with K9 Mark I and she appears to intend to marry Andred forms the basis for many Big Finish stories in both " The Companion Chronicles " and " Gallifrey " audio series . This story is also the ostensible link between " Doctor Who " and the Australian " K9 " series , since the K9 at the beginning of " Regeneration " appears to be the Mark I , who then " regenerates " into the model seen throughout that programme . Synopsis . The Doctor returns to Gallifrey , claims his rights and is inaugurated President . It soon turns out that he has led a group of aliens called Vardan s to the planet to eradicate them completely . After they are destroyed , the Sontarans take their opportunity and follow them in their invasion until they are destroyed by the Doctor . Plot . Part 1 . The Fourth Doctor meets a group of aliens in space and returns to Gallifrey , bringing Leela and K9 with him . He is behaving very strangely , and when the Chancellory Guard under their Commander , Andred , arrive at the Panopticon Chamber to interrogate him , the Doctor demands to be taken to Chancellor Borusa , who is now in charge of the Time Lord s . The Doctor claims the vacant Presidency of Gallifrey , having been a candidate . After the demise of Chancellor Goth , he is elected automatically . The aliens watch him keenly , stating that they have chosen well . The Doctor chooses a presidential chamber and asks it be decorated with lead lining throughout . Shortly afterward , a ceremony is held to swear him in as President of Gallifrey , and he is presented with the trappings of office . However , when the circlet connecting him to the Matrix , repository of all Time Lord knowledge , is placed on his head , the Doctor collapses in pain . Part 2 . The Doctor is taken to the Chancellory to rest and recover . When he regains consciousness , he reminds the Time Lords that no aliens are allowed on Gallifrey and instructs that Leela be expelled from the Capitol Citadel , where she will have to fend in the wastelands . She tries to avoid banishment , but the Doctor insists as president . The Doctor retreats to the TARDIS , where he shares a secret plan with K9 . He is obviously very concerned about the situation in which he has found himself . Meanwhile , Leela meets Rodan , and they find that a massive warship is moving towards Gallifrey . The Doctor is planning to aid an invasion of Gallifrey itself . To this end he sets about destroying the transduction barrier that shields the planet from external threat . K9 sets about this task while the Doctor returns to the Panopticon , the great hall of the Time Lords . He laughs cruelly as three alien beings start to materialise . Part 3 . The invading beings are known as Vardan s . They appear as shimmering manifestations who made an alliance with the Doctor some time ago . The Doctor advises the Time Lords , including the stubborn Borusa , to submit to their new and powerful masters . He asks Borusa to meet him in his office , where the Doctor explains he had the lead walls installed to prevent the Vardans entering the room on thought waves and reading his mind . He hadn ' t told the other Time Lords because their minds are too single - minded , and the Vardans would be able to hear them . He sent Leela away to protect her and can now work with Borusa to defeat the Vardan threat . A new problem has emerged , however , with the ascendancy of the obsequious and compliant Castellan Kelner . He is being far too co - operative with the Vardan occupation . The toadying yet ambitious Castellan soon has Borusa placed under house arrest and starts expelling trouble - making Time Lords from the safety of the Capitol . Leela has kept her faith in the Doctor . She decides that if he wishes her to leave the Capitol it is with good reason , so she departs for the wastelands . She is accompanied by Rodan . They are welcomed warily by a tribe of Outsider s who have rejected Time Lord society and live in the wastelands . Their leader , Nesbin , explains some of the background to his tribe . Back in the Capitol , however , things are looking grim for the Doctor when Andred corners him and decides to execute him in the name of liberty . Part 4 . K9 helps the Doctor overpower Andred . The Doctor explains the danger and abilities of the Vardans to Andred , with his TARDIS providing a shield to his thoughts . The Doctor is hoping to persuade the Vardans to fully materialise so that he can find their planet and time loop it . Leela has also organised her own resistance movement in the wastelands , comprising Nesbin ' s people and the exiled Time Lords , all of whom are drilled into a fighting force which soon launches an assault on the Capitol . Meanwhile , the aliens and Kelner have decided the Doctor is behaving in an untrustworthy manner . The Doctor reaffirms his loyalty to them by agreeing to dismantle the final force field protecting Gallifrey from attack . He does not fully disable it , but rather places a large hole in it . The Vardans use the hole to properly invade Gallifrey and appear as humanoid warriors . Their manifestation enables K9 to track down their home planet and supply the Doctor with the correct co - ordinates . He uses this to beam the Vardans back to their home world and then traps it in a time loop . At about the same time Leela and her warriors reach the Panopticon , but celebrations are short - lived when three Sontaran soldiers appears in the chamber , and the leader raises its gun . . . Part 5 . Gallifrey has now been invaded by the Sontarans , led by Commander Stor , who finds Kelner ever ready to pledge support , even if the other Time Lords remain resistant . The Doctor and his party escape to the President ' s office . Borusa has placed titanium alloy on the door to reinforce it . The Sontarans are delayed while the Doctor and his party escape through another exit . The Doctor uses his freedom to try to pressure Borusa into revealing to him the location of the Great Key of Rassilon , a missing item of the Presidential regalia . On the way back to the TARDIS , Nesbin is killed by a Sontaran . The Doctor looks for the Great Key in a large group of keys , and Borusa pulls it out of a drawer keyhole . Meanwhile , the Sontarans have been trying to get Kelner to widen the gap in the force field . They then regroup at the TARDIS where Rodan is put to work using the TARDIS ' controls to repair the hole in the force field , while the Doctor explains that the Sontarans want domination over all universes and all time . However , Kelner imperils their resistance when he manipulates the stabiliser banks of the Doctor ' s TARDIS to try to destroy the resistance force within by hurling them to the heart of a black star . . . Part 6 . The Doctor overrides the threat , so their enemies change tactics . Commander Stor and one of his troopers , assisted by Castellan Kelner , gain access to the Doctor ' s TARDIS . They pursue the Doctor and his friends through the labyrinth of corridors . Stor is after the Great Key too , knowing the Doctor has now persuaded Borusa to yield it to him . The Doctor uses distractions to buy time . On the Doctor ' s instruction , a hypnotised Rodan and K9 construct a special forbidden Time Lord weapon : the de - mat gun . Powered by the Great Key itself , the de - mat gun erases its victims from time itself . The Doctor takes the gun and confronts Stor in the Panopticon . Stor intends to destroy the galaxy , and the Time Lords and Sontarans with it , with a grenade , but the blast is cancelled out by the Doctor using the de - mat gun . It obliterates Stor , wipes the Doctor ' s mind of recent events , and also destroys itself . Kelner is arrested and Borusa begins the process of rebuilding Gallifrey . The Doctor is ready to leave , but Leela decides to stay on Gallifrey because she has fallen in love with Commander Andred . K9 decides to stay behind to look after Leela , and they both watch as the TARDIS dematerialises . Inside the TARDIS , the Doctor pushes out a box labelled " K9 MII . " He grins mischievously . Home video and audio releases . DVD releases . Bonus features : Notes : Boxed set release . This story was released in the " Bred for War " DVD boxset on 5 May alongside all the classic series Sontaran stories ( " The Time Warrior " , " The Sontaran Experiment " , " The Invasion of Time " and " The Two Doctors " ) . The DVD is the same as the one sold separately . It was released 8 July in Australia . VHS releases . This story was released as " Doctor Who : The Invasion of Time " . Released :