At this point, defeated Roman general Pompey the Great came to Egypt seeking refuge from his pursuing rival Julius Caesar. Initially, Ptolemy XIII pretended to have accepted his request, but on September 29, 48 BC, he had the general murdered in hopes of winning favor with Caesar when the victorious general arrived. When Caesar arrived he was presented with the head of his deceased rival and former ally, but reportedly, instead of being pleased, Caesar reacted with disgust and ordered that Pompey's body be located and given a proper Roman funeral. Cleopatra VII proved more successful in winning Caesar's favor and became his lover. Caesar arranged the execution of Pothinus and the official return to the throne of Cleopatra VII, though she had never officially abdicated her marriage to Ptolemy XIII.
Still determined to depose Cleopatra VII, Ptolemy XIII allied himself with Arsinoe 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 48 BC inside Alexandria itself, which suffered serious damage as a result.
Upon the arrival of Roman reinforcements, the Battle of the Nile ensued and resulted in a victory for Caesar and Cleopatra, forcing Ptolemy XIII to flee the city. Ptolemy XIII reportedly drowned on January 13, 47 BC while attempting to cross the Nile. Whether he was attempting to flee or was seeking negotiations remains uncertain from sources of the time. Cleopatra VII remained the unchallenged ruler of Egypt, although she named their younger brother Ptolemy XIV of Egypt her new co-ruler.