Doctor Who: The Invasion of Time (1978)
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 Vardans 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.