Sontaran invasion of Gallifrey

hmm...

The Sontaran invasion of Gallifrey, also referred to as the Vardan/Sontaran invasion or Sontaran/Vardan invasion, (PROSE: The Eight Doctors) was an attempt by the Sontaran Empire to take control of Time itself. (TV: The Invasion of Time)

The invasion occurred at some point before Sontaran martial year 5709. (AUDIO: Heroes of Sontar)

Prelude
After assassinated the Time Lord President, the Fourth Doctor put himself forward as a candidate for election to gain legal protection as he was believed to be the assassin, and the Time Lords were threatening him with vaporisation. 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 office of President. (TV: The Deadly Assassin)

The invasion
The Vardans, who wished to invade Gallifrey, later contacted the Doctor. As part of an elaborate plan where he would pretend to help them so he could deal with the Vardans as they were a threat, he agreed to help them. He arrived on Gallifrey and claimed the title of President, then deactivated the transduction barrier. The Capitol was placed under Vardan control. The Doctor had duped them, however, and ultimately defeated them, sealing Varda in a time loop.

Indeed, 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, helped by the sycophantic Castellan, Kelner.

The Doctor retreated into his TARDIS along with Leela, Andred,, 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 galaxy, including the Time Lords. The Doctor fired the Demat Gun, obliterating Stor and causing the Demat Gun to disappear. This action came at the cost of the Doctor losing all memory of the invasion,(TV: The Invasion of Time) only for him to later regain his knowledge of the affair. (TV: The Ribos Operation, et. al)

Aftermath
The Doctor later remarked that he wished he'd thrown the President to the Sontarans while he had the chance. (TV: The Ribos Operation)

Romana I had witnessed the panic of Gallifrey being invaded, later noting the same panic when a mountain in Shangdong almost blew up. (PROSE: The Shadow of Weng-Chiang)

In the years that followed, details of the invasion were taught at the Time Lord Academy. (AUDIO: Insurgency) The invasion was also the event that revealed the existance of the Matrix to the universe at large. As such, the Cloister Wars began. (PROSE: Dalek: The Astounding Untold History of the Greatest Enemies of the Universe)

Noticing that Thessalia had regenerated, Larissa wondered if it had been during "the goblin infestation". (PROSE: Newtons Sleep)

By the Last Great Time War, the Doctor was recognised as the "saviour of Gallifrey in the war with the Vardans". (PROSE: Dalek Combat Training Manual)

Behind the scenes

 * Commander Stor and his battle on Gallifrey is mentioned by Commander Strax in the fourth-wall-breaking cinema intro for The Day of the Doctor. He is disappointed to learn that the anniversary feature is about the Doctor as opposed to a Sontaran historical drama featuring heroic accounts of their various military campaigns which he was anticipating with his clone batch.