Alexandria, founded in 332 B.C. by Alexander the Great, was (304–30 B.C.) the capital of the Ptolemies. The city took over the trade of Tyre (sacked by Alexander the Great), outgrew Carthage by c.250 B.C., and became the largest city in the Mediterranean basin. It was the greatest center of Hellenistic civilization and Jewish culture. The Septuagint, a translation of the Old Testament into Greek, was prepared there. Alexandria had two celebrated royal libraries, one in a temple of Zeus and the other in a museum. The collections were said to contain c.700,000 rolls. A great university grew around the museum and attracted many scholars, including Aristarchus of Samothrace, the collator of the Homeric texts; Euclid, the mathematician; and Herophilus, the anatomist, who founded a medical school there.
Julius Caesar temporarily occupied (47 B.C.) the city while pursuing Pompey, and Octavian (later Augustus) entered it (30 B.C.) after the suicide of Antony and Cleopatra. Alexandria formally became part of the Roman Empire in 30 B.C. It was the greatest of the Roman provincial capitals, with a population of about 300,000 free persons and numerous slaves. In the later centuries of Roman rule and under the Byzantine Empire, Alexandria rivaled Rome and Constantinople as a center of Christian learning. It was (and remains today) the seat of a patriarch of the Eastern Orthodox Church.
The libraries, however, were gradually destroyed from the time of Caesar's invasion, and suffered especially in A.D. 391, when Theodosius I had pagan temples and other structures razed. When the Muslim Arabs took Alexandria in 642, its prosperity had withered, largely because of a decline in shipping, but the city still had about 300,000 inhabitants. The Arabs moved the capital of Egypt to Cairo in 969 and Alexandria's decline continued, accelerating in the 14th cent., when the canal to the Nile silted up.
During his Egyptian campaign, Napoleon I took the city in 1798, but it fell to the British in 1801. At that time Alexandria's population was only about 4,000. The city gradually regained importance after 1819, when the Mahmudiyah Canal to the Nile was completed by Muhammad Ali, who developed Alexandria as a deepwater port and a naval station.
During the 19th cent. many foreigners settled in Alexandria, and in 1907 they made up about 25% of the population. In 1882, during a nationalist uprising in Egypt spearheaded by Arabi Pasha, there were antiforeign riots in Alexandria, which was subsequently bombarded by the British. During World War II, as the chief Allied naval base in the E Mediterranean, Alexandria was bombed by the Germans. In a 1944 meeting in Alexandria, plans for the Arab League were drawn up. The city's foreign population declined during the 20th cent., particularly after the 1952 Egyptian revolution.