Recent radiocarbon dating of seashell fragments and lead contamination show human activity at the location during the period of the Old Kingdom (27th–21st centuries BC) and again in the period 1000–800 BC, followed by the absence of activity thereafter. From ancient sources it is known there existed a trading post at this location during the time of Rameses the Great for trade with Crete, but it had long been lost by the time of Alexander’s arrival. A small Egyptian fishing village named Rhakotis (Egyptian: rꜥ-qdy.t, ‘That which is built up’) existed since the 13th century BC in the vicinity and eventually grew into the Egyptian quarter of the city. Just east of Alexandria (where Abu Qir Bay is now), there were in ancient times marshland and several islands. As early as the 7th century BC, there existed important port cities of Canopus and Heracleion. The latter was recently rediscovered under water.

Alexandria was founded by Alexander the Great in April 331 BC as Ἀλεξάνδρεια (Alexandreia). After he captured the Egyptian Satrapy from the Persians, Alexander wanted to build a large Greek city on Egypt’s coast that would bear his name. He chose the site of Alexandria, envisioning the building of a causeway to the nearby island of Pharos that would generate two great natural harbours.[10] Alexandria was intended to supersede the older Greek colony of Naucratis as a Hellenistic centre in Egypt, and to be the link between Greece and the rich Nile valley. A few months after the foundation, Alexander left Egypt and never returned to the city during his life.

After Alexander’s departure, his viceroy Cleomenes continued the expansion. The architect Dinocrates of Rhodes designed the city, using a Hippodamian grid plan. Following Alexander’s death in 323 BC, his general Ptolemy Lagides took possession of Egypt and brought Alexander’s body to Egypt with him. Ptolemy at first ruled from the old Egyptian capital of Memphis. In 322/321 BC he had Cleomenes executed. Finally, in 305 BC, Ptolemy declared himself Pharaoh as Ptolemy I Soter (“Savior”) and moved his capital to Alexandria.

Although Cleomenes was mainly in charge of overseeing Alexandria’s early development, the Heptastadion and the mainland quarters seem to have been primarily Ptolemaic work. Inheriting the trade of ruined Tyre and becoming the centre of the new commerce between Europe and the Arabian and Indian East, the city grew in less than a generation to be larger than Carthage. In one century, Alexandria had become the largest city in the world and, for some centuries more, was second only to Rome. It became Egypt’s main Greek city, with Greek people from diverse backgrounds.

The Septuagint, a Greek version of the Tanakh, was produced there. The early Ptolemies kept it in order and fostered the development of its museum into the leading Hellenistic centre of learning (Library of Alexandria, which faced destruction during Caesar’s siege of Alexandria), but were careful to maintain the distinction of its population’s three largest ethnicities: Greek, Egyptian and Jewish. By the time of Augustus, the city grid encompassed an area of 10 km2 (3.9 sq mi) and the total population during the Roman principate was around 500,000–600,000, which would wax and wane in the course of the next four centuries under Roman rule.

According to Philo of Alexandria, in the year 38 AD, disturbances erupted between Jews and Greek citizens of Alexandria during a visit paid by King Agrippa I to Alexandria, principally over the respect paid by the Herodian nation to the Roman emperor, and which quickly escalated to open affronts and violence between the two ethnic groups and the desecration of Alexandrian synagogues. This event has been called the Alexandrian pogroms. The violence was quelled after Caligula intervened and had the Roman governor, Flaccus, removed from the city.

In 115 AD, large parts of Alexandria were destroyed during the Kitos War, which gave Hadrian and his architect, Decriannus, an opportunity to rebuild it. In 215 AD, the emperor Caracalla visited the city and, because of some insulting satires that the inhabitants had directed at him, abruptly commanded his troops to put to death all youths capable of bearing arms. On 21 July 365 AD, Alexandria was devastated by a tsunami (365 Crete earthquake), an event annually commemorated years later as a “day of horror”.