After Caesar's great victory at Pharsalus, all was not yet won. The Pompeians still controlled the seas, Africa was in their hands and Juba of Numidia was siding with them. Caesar was not yet master of the empire.
Therefore, at the first possible moment, Caesar had set out with a small force after Pompey and, evading the enemy fleets, tracked him all the way to Egypt, where the Egyptian government's envoys received him, not with his dead rival's head.
But rather than being able to swiftly move on ad deal with the remaining Pompeians, Caesar became entangled in Egyptian politics. He was asked to help settle a dispute between the young king Ptolemy XII and his fascinating sister Cleopatra.
Though the arrangements Caesar suggested for the dynasty gave such offence to Ptolemy and his ministers that they set the royal army upon him and kept him and his small force blockaded in the palace quarter of Alexandria through the winter of 48/47 BC.
With his force of no more than 3000 men Caesar became involved in desperate rounds of street-fighting against the Ptolemaic royal troops.
Meanwhile, the Pompeians seeing their chance to rid themselves of their foe, used their fleets to prevent any reinforcements reaching him.
Alas, a makeshift force swept together jointly in Cilicia and Syria by a wealthy citizen of Pergamum, known as Mithridates of Pergamum, and by Antipater, a Judaean government minister, managed to land and help Caesar out of Alexandria.
A few days later the 'Alexandrian War' was ended in a pitched battle on the Nile delta, in which both the king Ptolemy XII and the true power behind the throne, his chief-minister Achillas, met their death.
The late king's crown was transferred by Caesar to his younger brother Ptolemy XIII. But the effective ruler of Egypt henceforth was Cleopatra whom Caesar invested a co-regent.
Wether true or not is unclear, but Caesar is said to have spent up to two months with Cleopatra on a holiday tour up the Nile.