Sontaran invasion of Gallifrey

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

Prelude
When the Third Doctor encountered the Sontaran, Linx, on Earth in the 13th century, he informed him that he was a Time Lord from Gallifrey. The Sontaran revealed that he knew of the Doctor's world and people. Linx considered the Time Lords to be "a race of great technical achievement, but lacking the morale to withstand a determined assault" — which made the Doctor invite him to "put that theory to the test". (DW: The Time Warrior)

After the Master assassinated the Time Lord President, the Fourth Doctor put himself forward as a candidate for election 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 office of President. (DW: The Deadly Assassin)

The Invasion
The Vardans, who wished to invade Gallifrey, later contacted the Doctor. As part of an elaborate plan, 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.

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, 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 disappeared and the Doctor lost all memory of the invasion. (DW: The Invasion of Time)

Aftermath
In the years that followed, details of the invasion were taught at the Time Lord Academy. (BFG: Insurgency)