The Ptolemaic Kingdom was a Greek dynasty which ruled over Egypt from 305 BC to 30 BC, with Alexandria serving as its capital. The kingdom was established by Ptolemy I Soter, a general of Alexander the Great, who was entrusted with Egypt, the Levant, and other patrs of Africa upon Alexander's death and the division of his empire. Ptolemy proclaimed himself Pharaoh and created a powerful Macedonian Greek dynasty which stretched from southern Syria in the north to Cyrenaica in the west and Nubia to the south. The capital city of Alexandria became a major city of Greek culture and trade, and the Ptolemies oversaw a fusion of Greek and Egyptian cultures; later Ptolemies married their siblings per the Osiris myth, had themselves portrayed in Egyptian style and dress, and participated in Egyptian religious life. The Ptolemies were involved in foreign and civil wars that led to the kingdom's decline, often fighting against the Seleucids of Syria for control of the Levant.
In 200 BC, the Seleucids defeated the Egyptians at Panium, conquering Syria; the Ptolemies sought an alliance with the Roman Republic for survival. During the 2nd century, several Pharaohs were killed in civil wars as the Seleucids invaded and the Egyptian administration collapsed, and the dynastic quarrels ensured that Egypt essentially became a Roman protectorate. In 48 BC, the Roman general Julius Caesar was sent to intervene in the Alexandrine Civil War between Cleopatra and her brother Ptolemy XIII, resulting in the Battle of the Nile in 47 BC, at which Ptolemy drowned. Cleopatra became Caesar's lover and his ally, and, after Caesar's murder in 44 BC, his right-hand man Mark Antony became Cleopatra's new lover.
Antony, entrusted with Rome's eastern provinces, was nearly fooled into handing over these provinces to Egypt, but he proclaimed his intent to be buried in Egypt instead of Rome, angering the Romans at the court of his rival, Caesar's nephew Octavian. In 31 BC, Octavian declared war on Antony and Cleopatra, defeating their fleet at the Battle of Actium before invading Egypt. Alexandria fell, and Antony and Cleopatra committed suicide rather than be captured by Octavian. Octavian then had the last Pharaoh of Egypt, Caesarion, murdered, and the Ptolemaic Kingdom became the Roman province of Aegyptus.