The Berbers have occupied North Africa, specifically the Maghreb, since the beginning of recorded history and until the Islamic conquests of the 8th century CE constituted the dominant ethnic group in the Saharan region. Modern Berber speakers and cultural practitioners are a minority in North Africa, though Berber groups are considered the descendants of pre-Arab inhabitants of the region. In most classical texts they are referred to as Libyans. A widely-distributed and diverse ethnic group, the ancient Berbers spoke a subset of the Afro-Asiatic languages, linguistically related to that of the Egyptians, Kushites, Arabs, Syrians, Levantine tribes, and Somalis. Known to themselves as Amazigh, the Berbers take their more common name from the Latin barbarus (barbarian), a Roman effort to distinguish the less-developed tribal societies of much of Europe and Africa from their own Hellenic-derived civilization. Libya is a Greek word derived from a regional title, and the term came to be used interchangeably with the concept of Africa.
Origins of the Libyans
The presence of proto-Berber peoples from prehistory is evident in Saharan caves, where rock paintings depicting diverse megafaunal life point to evidence that before the desertification of the Sahara, northern Africa was a lush and resource-rich region populated by hunter-gatherer societies. The basal two deities of Berber cosmology - a solar figure and a lunar one - are loosely analogous to those of the Egyptians, suggesting a common cultural origin. According to Herodotus, who in his Histories wrote of the Berbers in 430 BCE,
They sacrifice to the Sun and Moon, but not to any other god. This worship is common to all the Libyans. (IV, 198)
In common with pre-Abrahamic Middle Eastern peoples, the importance of rocks was a major theme in Berber tradition. Some stone-cut mausoleums, such as the Roman-era Royal Mausoleum of Mauritania, built by Berber kings in traditional style, remain intact today. The Berber veneration of stone structures, which included the burial of the dead under outcroppings or erected monuments, was akin to such practices as the Nabatean pilgrimage to the Black Stone at Mecca’s Kaaba and the Arabian Hutaymi people's worship of the great boulder Al-Weli abu Ruzuma. Similarities in tradition and language point to an ancient proto-Afroasiatic cultural center from which these groups dispersed.
Relations with Egypt
The existence of powerful semi-nomadic tribes inhabiting the Maghreb was noted by Egyptian dynasties since the 13 century BCE; certain of these engaged in armed conflict with the Egyptians and thus among the pharaonic dynasties came to be regarded negatively and their societies styled as barbarian. The most notable groups from this period are the Meshwesh and Ribu, the latter from which the Greco-Latin term Libya is derived. A system of hieroglyphic writing was developed by the early Berbers, clearly derived from that of the more scripturally sophisticated Egyptians and evidencing strong cultural influence from the Nile region. The 3rd century BCE saw a literary shift in that Libyans began to form their own script based mainly on the Phoenician alphabet.
The Libyans were not always inclined to view the Egyptians as foes, however, in that they were willing to tolerate a certain level of protection from the pharaohs. In the 6th century BCE, Greek colonists began establishing an even greater presence at their established Libyan city of Cyrene. According to historian Susan Wise Bauer,
This did not go over well for the native North Africans [...] They sent a message to Egypt asking for help, and 'put themselves in the protection of the Egyptian king Apries.' So Apries sent out an Egyptian army [which] was decimated by the Greeks: they were, in Herodotus's words, 'so thoroughly annhiliated that hardly any of them found their way back to Egypt.' (502)
By the time Carthage was founded under Phoenician thalassocracy in the 9th century BCE, larger Berber groups had already transitioned from hunter-gathering and pastoralism to sedentary pastoral-agricultural organization.
Native North Africans provided seafaring Phoenician colonists exactly what they were looking for: trading partners. On the coast, agriculture - likely adopted far earlier from interaction with Egypt and Fertile Crescent societies - became a dominant feature of Berber society. The two most prominent Libyan sedentary societies emerged by the 2nd century BCE: Numidia and Mauretania. Carthage, as a city-state, did not occupy an extensive land area and outside the Tunisian peninsula and the North African coast did not have much direct influence. Thus the Libyan kingdoms of the Numidians and Mauri enjoyed, at least for most of their history alongside Carthage, an independent commercial relationship. Numidian Berbers were also a major demographic within Carthage itself, though Phoenicians occupied the nobility and merchant classes, relegating natives mainly to serfdom and military conscription. During this time the Greeks began documenting North Africa and its kingdoms, shedding more light on the Berber tribes and their relationship with Carthage and being the first to refer to the people of the Maghreb as Libyans.
Mauretania, lying to the east of the Tunisian peninsula, traded heavily with Carthaginian claims on the North African coast. Led by tribal kings, the Mauri joined forces with Massinissa of Numidia (238-148 BCE) during the Second Punic War, joining forces against Carthage. The Roman term Mauri is the precursor to the term Moors used in later centuries to refer to the inhabitants of northeastern Africa.
Numidians were prized for their horsemanship and thus made up a significant portion of the Carthaginian cavalry during the Punic Wars. However, the standing of the Numidian kingdom with Carthage changed dramatically during the Second Punic War. Massinissa, the powerful son of a Numidian chieftain and an ally of Carthage, betrayed the city when he saw that it was losing ground to Scipio’s forces in the Iberian peninsula. He joined forces with the Roman Republic in 206 BCE. As a result, Massinissa was secured Roman backing to the throne of Numidia and helped defeat the Carthaginians at the Battle of Zama in which Hannibal was finally captured. The decisive victory ended the Second Punic War and legitimized Numidia as a Roman client state. Albeit restrained, Roman jurisdiction over Numidia under the rule of Massinissa led to a technological advancement of tribal Numidian Berber society, with most citizens moving to a complete sedentary agricultural way of life and the state participating in a growing Mediterranean trade sphere.
Two years prior to the sacking of Carthage in 146 BCE, the Roman Republic decided to legitimize various Numidian tribal leaders as heads of their own respective Numidian client states, likely to ensure stability and curb the prospects of a single Libyan ruler creating an empire in North Africa at the expense of Rome. All were grouped under Africa Proconsularis. However, subsequent chieftains made efforts to consolidate power in the region.
A century after the Roman victory in the Second Punic War, a leader named Jugurtha (160-140 BCE) bribed Roman authorities for occupation of the throne of Numidia and ousted the client establishment, leading to the Jugurthine War, the first major conflict between Rome and an independent Numidia. Jugurtha was captured and killed. Numidian relations as a client region would remain peaceful until the ascent of Juba II (85-46 BCE), a chieftain who united the Numidians and Mauretanians against Julius Caesar. Likely wary of the potential establishment of Numidia as a directly-occupied imperial province instead of a client state, Juba sided with the Pompeians of the Republic during the Great Roman Civil War, a decision that cost him his life at the Battle of Thapsus in 46 BCE. The defeat ended the war and established Caesar as dictator. Caesar carved the existing province of Numidia into a new political entity, fully annexing it as the province of Africa (Africa Nova), which was in subsequent years renamed and reestablished as Numidia (Africa Proconsularis).
During these years of imperial reorganization, Roman jurisdiction over Mauretania was likewise changed from a client state relationship to provincial annexation. The political identity of Numidian Berbers did not change significantly during the Roman period; there was little if any Romanization among the tribes even though leaders were usually loyal clients and responded well to Roman rule. Only the Abrahamic religions - first Christianity, then Islam - would fundamentally change Berber way of life, and even then numerous ancient traditions would remain and prosper.