The Doctor, Bill, and Nardole land in second century Scotland as part of a bet between the Doctor and Bill over the legendarily mysterious fate of the Roman Legio IX Hispana, the Ninth Legion.
The Doctor and Nardole head one way, while Bill another. Bill encounters a Scot (later revealed to be Kar) and runs away. Falling down a hole, she encounters a Roman legionary who is hiding.
The Roman, one of the few survivors of the Ninth Legion, warns her of a monster that slaughtered the army. He tells her where to find the few remaining survivors before he, too, is killed by the beast.
Nardole and the Doctor, meanwhile, are captured by the local Scots and meet Kar, their leader, who is called the Gatekeeper. The Doctor realizes she is meant to guard an interdimensional doorway, and the monster is from the other side.
She intentionally let it through to slaughter the invading Romans, but it proved to be far more dangerous than she anticipated. Eating the light, it will only grow more powerful, eventually consuming the sun and all the stars in the universe.
Bill leads the remaining Roman survivors and reunites with the Doctor. The Romans work together with the Scots to lure the creature back to the portal, where they force it back through.
Then the Romans and Kar enter the portal to ensure that no other creatures make their way through again.
Back on the TARDIS, the Doctor reveals that Missy is out of the Vault and actually doing maintenance work. He is unsure of whether or not to trust her appearance of contrition.