Cleopatra VII Philopator was the last active ruler of the Ptolemaic Kingdom of Egypt, nominally survived as pharaoh by her son Caesarion. As a member of the Ptolemaic dynasty, she was a descendant of its founder Ptolemy I Soter, a Macedonian Greek general and companion of Alexander the Great. After the death of Cleopatra, Egypt became a province of the Roman Empire, marking the end of the Hellenistic period that had lasted since the reign of Alexander (336–323 BC). Her native language was Koine Greek, and she was the first Ptolemaic ruler to learn the Egyptian language.
In 58 BC, Cleopatra presumably accompanied her father Ptolemy XII during his exile to Rome after a revolt in Egypt, a Roman client state, allowed his daughter Berenice IV to claim the throne. Berenice was killed in 55 BC when the king returned to Egypt with Roman military assistance. When he died in 51 BC, the joint reign of Cleopatra and her brother Ptolemy XIII began. A falling-out between them led to open civil war. After losing the 48 BC Battle of Pharsalus in Greece against his rival Julius Caesar in Caesar's Civil War, the Roman statesman Pompey fled to Egypt, where Ptolemy had him killed while Caesar occupied Alexandria. Caesar had attempted to reconcile the siblings, but Ptolemy's chief adviser Potheinos viewed Caesar's terms as favoring Cleopatra, so his forces besieged her and Caesar at the palace. Shortly after the siege was lifted by reinforcements, Ptolemy died in the 47 BC Battle of the Nile. His sister Arsinoe IV was eventually exiled to Ephesus for her role in carrying out the siege. Caesar declared Cleopatra and her brother Ptolemy XIV joint rulers, but maintained a private affair with Cleopatra that produced Caesarion. Cleopatra traveled to Rome as a client queen in 46 and 44 BC, where she stayed at Caesar's villa. After the assassinations of Caesar and (on her orders) Ptolemy XIV in 44 BC, she named Caesarion co-ruler.