Alternate timeline (The Book of Shadows)

An alternate timeline was once created by Rhakotis when he crash-landed into the Mediterranean Sea, near Alexandria in 331 BC. After gaining favour with the rulers there, Alexander the Great and Ptolemy Lagus, Rhakotis decided to provide them with advanced technology in return for them helping him retrieve his ship from the depths of the sea. One such piece of technology were the time travel portals installed in the royal library which allowed the travelling to other points in time in the city's history.

Before the construction of these portals, Barbara Wright arrived from 322 BC by one of the portals as it stood in this future time. She met Ptolemy and eventually married him, producing a son called Ptolemy Philadelphus. Ptolemy later became King of Egypt, with Barbara as his Queen.

At some point, The Worshipful and Ancient Law of Gallifrey was acquired from 20th century Cambridge by Aristotle, where it was kept in the city's royal library.

In 322 BC, the First Doctor, Barbara Wright and Ian Chesterton arrived in an Alexandrian gold mine. With Ian and the TARDIS becoming buried by rubble, the Doctor and Barbara were taken to the city, as Barbara was mistaken for the Queen, who was actually her future self. It wasn't long before Barbara accidentally stumbled into one of the portals, ended up in 331 BC, and the chain of events leading to this point occurred.

The timeline was eventually reverted when Queen Barbara read from the The Worshipful and Ancient Law of Gallifrey which, with its immense power, was able to unwrite the changes to history such that the TARDIS never landed in Alexandria and Rhakotis was killed on impact, preventing the the events which encompassed the timeline. (PROSE: The Book of Shadows)