Sontaran invasion of Gallifrey

The Sontaran invasion of Gallifrey was an attempt by the Sontaran Empire to take control of Time itself.

After the Master assassinated the Time Lord President, the Doctor put himself forward as a candidate for election in order to gain legal protection. The only other candidate was Goth, who was in league with the Master and who was subsequently killed. The Doctor left Gallifrey without assuming the role of President. (DW: The Deadly Assassin)

The Doctor was later contacted by the Vardans, who wished to invade Gallifrey. As part of an elaborate plan, the Doctor agreed to help them. He arrived on Gallifrey and claimed the title of President. The Doctor deactivated the transduction barrier and the Capitol was placed under Vardan control. The Doctor had duped them, however, and ultimately defeated them, sealing Varda in a time loop.

However, the Vardans had been doubly duped. Their invasion was no more than a front for the Sontarans, who marched into the Panopticon and took control. The Sontarans, led by Stor, easily overcame Time Lord resistance, and were helped by the sycophantic Castellan, Kelner.

The Doctor retreated into his TARDIS along with Leela, Andred, Borusa, Rodan and K9 Mark I. The Doctor had consulted the Matrix and had learnt how to construct the fabled Demat Gun. He placed Rodan under hypnosis and instructed her to build the weapon.

The Sontarans pursued the Doctor through the TARDIS but were defeated. Stor went to the Panopticon in a last-ditch suicide attempt to destroy the Eye of Harmony. The Doctor fired the Demat Gun, obliterating Stor. The Demat Gun then disappeared and the Doctor lost all memory of the invasion. (DW: The Invasion of Time)