In 49 BCE, the Order of the Ancients manipulated Ptolemy XIII to exile his sister Cleopatra from Egypt, desiring to seize power for themselves. Cleopatra, with the help with her follower Apollodorus, was able to escape Alexandria through the canals, preventing her capture.
The following year, Cleopatra began working with her followers to regain enough power and challenge her brother for the throne. With aid from her agent Aya, and her husband, the Medjay Bayek of Siwa, they were able to eliminate members from the Order of the Ancients one by one to diminish their influence in the country. Cleopatra was also able to secure an alliance with the Roman general Pompey, who fled from Rome during the Roman Civil War.
Still determined to depose Cleopatra, Ptolemy XIII allied himself with Cleopatra's sister, Arsinoë IV. Jointly, they organized the factions of the army loyal to them against those loyal to Cleopatra VII and the relatively small part of his army that had accompanied Caesar to Egypt. The battle between the warring factions occurred in mid-December 47 BCE inside Alexandria itself, which caused serious damage as a result. 
In the Battle of the Nile, Cleopatra and Caesar won a decisive battle against Ptolemy's army, resulting in the deaths of Ptolemy himself and Pothinus. Cleopatra was thus declared the sole and unchallenged ruler of Egypt.