The history of North Africa during the period of classical antiquity (c. 8th century BCE – 5th century CE) can be divided roughly into the history of Egypt in the east, the history of ancient Libya in the middle and the history of Numidia and Mauretania in the West.
 Initially, in the east, Egypt was under Persian rule during the early phase of classical antiquity, passing to the Ptolemaic dynasty in the Hellenistic era.  Libya was inhabited by Berber tribes, while along the coast Phoenician and Greek colonies were set up.
 The Roman Republic established the province of Africa in 146 BCE after the defeat of Carthage. The Roman Empire eventually controlled the entire Mediterranean coast of Africa, adding Egypt in 30 BCE, Crete and Cyrenaica in 20 BCE, and Mauretania in CE 44.
 The Western Roman Empire lost most parts of Africa to the Vandals in the 5th century. They were reincorporated into the Roman realm by the Eastern Roman Empire in the 6th century. Later, the empire finally lost all control of Africa as the region fell to the Umayyad conquest of North Africa by the close of the 7th century.
 The Late Period of ancient Egypt refers to the last flowering of native Egyptian rulers after the Third Intermediate Period from the Saite Twenty-sixth Dynasty of Egypt into Persian conquests and ending with the fall of the Thirty-First (Second Persian) Dynasty to the conquest of Alexander the Great in 332 BCE. After Alexander's death in 323 BCE, Egypt fell to Ptolemy I Soter who eventually established the Ptolemaic Kingdom in 305 BCE.
 In 2013, the first genetic analysis utilizing next-generation sequencing was conducted to ascertain the ancestral lineage of an Ancient Egyptian individual. DNA was extracted from the heads of five Egyptian mummies. All the specimens were dated to between 806 BC and 124 AD, a timeframe corresponding with the Late Dynastic and Ptolemaic periods. The researchers observed that one of the mummified individuals likely belonged to the mtDNA haplogroup I2, a maternal clade believed to have originated in Western Asia.
 Phoenician traders arrived on the North African coast around 900 BC and established Carthage (in present-day Tunisia) around 800 BCE. By the 6th century BCE, a Punic presence existed at Tipasa (east of Cherchell in Algeria). From their principal center of power at Carthage, the Carthaginians expanded and established small settlements (called emporia in Greek) along the North African coast; these settlements eventually served as market towns as well as anchorages. Hippo Regius (modern Annaba) and Rusicade (modern Skikda) are among the towns of Carthaginian origin on the coast of present-day Algeria.
 As Carthaginian power grew, its involvement in the indigenous population increased dramatically. Berber civilization was already at a stage in which agriculture, manufacturing, trade, and political organization supported several states. Trade links between Carthage and the Berbers in the interior grew and thus created a new Punic society speaking Punic, but territorial expansion also resulted in the enslavement or military recruitment of some Berbers and in the extraction of tribute from others.
 Egypt was not considered part of Libya (Africa) in Hellenistic geography. The boundary between Africa and Asia was at  Catabathmus Magnus, separating Libya proper (or Marmarica) from the "Libyan Nomos" (Λιβύης νόμος) of western Egypt.
 In the Mercenary War, Berber soldiers participated from 241 to 238 BCE after being unpaid following the defeat of Carthage in the First Punic War. Berbers succeeded in obtaining control of much of Carthage's North African territory, and they minted coins bearing the name Libyan, used in Greek to describe natives of North Africa. The Carthaginian state declined because of successive defeats by the Romans in the Punic Wars; in 146 BCE the city of Carthage was destroyed.
 As Carthaginian power waned, the influence of Berber leaders in the hinterland grew. By the 2nd century BCE, several large but loosely administered Berber kingdoms had emerged. Two of them were established in Numidia, behind the coastal areas controlled by Carthage. West of Numidia lay Mauretania, which extended across the Moulouya River in Morocco to the Atlantic Ocean. 
The high point of Berber civilization, unequaled until the coming of the Almohads and Almoravids more than a millennium later, was reached during the reign of Masinissa in the 2nd century BCE. After Masinissa's death in 148 BC, the Berber kingdoms were divided and reunited several times. Masinissa's line survived until CE 24, when the remaining Berber territory was annexed to the Roman Empire.
 Roman domination of the northern Mediterranean coasts of Africa began when Carthage was defeated. The Roman Empire in the following century controlled all the coasts from the Nile valley to the Atlantic Ocean of modern Morocco.
 The Roman military presence of North Africa was relatively small if related to other areas of the empire, consisting of about 28,000 troops and auxiliaries in Numidia and the two Mauretanian provinces. Starting in the 2nd century CE, these garrisons were manned mostly by local inhabitants, because the area was considered fully pacified and nearly totally romanised.
 Aside from Carthage, urbanization in North Africa came in part with the establishment of settlements of veterans under the Roman emperors Claudius, Nerva, and Trajan.
 In what is now Algeria, such settlements included Tipasa, Cuicul or Curculum (modern Djemila, northeast of Sétif), Thamugadi (modern Timgad, southeast of Sétif), and Sitifis (modern Setif). The prosperity of most towns depended on agriculture. Called the "granary of the empire," North Africa was one of the largest exporters of grain in the empire, which was exported to other provinces, like Italy and Greece. Other crops included fruit, figs, grapes, and beans. By the 2nd century CE, olive oil rivaled cereals as an export item.
 The beginnings of the decline were less serious in North Africa than elsewhere. There were uprisings, however. In CE 238, landowners rebelled unsuccessfully against the emperor's fiscal policies. Sporadic tribal revolts in the Mauretanian mountains followed from 253 to 288. The towns also suffered economic difficulties, and building activity almost ceased.
 The towns of Roman North Africa had a substantial Jewish population. Some Jews had been deported from Judea or Palestine in the 1st and 2nd centuries CE for rebelling against Roman rule; others had come earlier with Punic settlers. In addition, a number of Berber tribes had converted to Judaism.
 Early Christianity arrived in the 2nd century and soon gained converts in the towns and among slaves. More than eighty bishops, some from distant frontier regions of Numidia, attended the Council of Carthage in 256. By the end of the 4th century, the settled areas had become Christianized, and some Berber tribes had converted en masse.
 A division in the church that came to be known as the Donatist controversy began in 313 among Christians in North Africa. The Donatists stressed the holiness of the church and refused to accept the authority to administer the sacraments of those who had surrendered the scriptures when they were forbidden under the Emperor Diocletian. The Donatists also opposed the involvement of Emperor Constantine in church affairs in contrast to the majority of Christians who welcomed official imperial recognition.
 The occasionally violent controversy has been characterized as a struggle between opponents and supporters of the Roman system. The most articulate North African critic of the Donatist position, which came to be called a heresy, was Augustine, bishop of Hippo Regius. Augustine maintained that the unworthiness of a minister did not affect the validity of the sacraments because their true minister was Christ. In his sermons and books Augustine, who is considered a leading exponent of Christian dogma, evolved a theory of the right of orthodox Christian rulers to use force against schismatics and heretics. Although the dispute was resolved by a decision of an imperial commission in Carthage in 411, Donatist communities continued to exist as late as the 6th century.
 In the summer of 365 AD, a massive tsunami struck North Africa, causing massive damage and thousands of deaths. The cities were devastated and coastal farmlands ruined by seawater. Almost total crop failure precipitated a steep decline in trade. This decline in trade weakened Roman control. Independent kingdoms emerged in mountainous and desert areas, towns were reconquered by Berbers. Then the Vandals took over most of Africa Proconsularis in the early 5th century and stayed for a hundred years.
 Belisarius, general of the Byzantine emperor Justinian I based in Constantinople, landed in North Africa in 533 with 16,000 men and within a year destroyed the Vandal kingdom. Many rural areas reverted to Berber rule and Byzantine North Africa as a whole was lost during the Muslim conquests.