Early history

The earliest known inhabitants of certain areas of Algeria were cattleherds and hunters living in the Al Hajjar region between 8,000 and 2,000BC. These may have been tribal Berbers. Phoenicians settled some of the coastal areas of Algeria from their north-African state of Carthage which was in modern day Tunisia.
The first Algerian kingdom was established by the Berber chieftain Massinissa during the Punic Wars between Rome and Carthage which took place between the 3rd and 2nd centuries BC. Massinissa reigned over his kingdom of Numidia from 202-148BC and his dynasty lasted until 106BC when his grandson Jugurtha became a Roman client. As part of the Roman Empire Numidia flourished, becoming known as the 'granary of Rome'. A road system and a series of Roman garrisons which became small Roman cities were built during the Roman period.
With the decline of the Roman Empire, Roman armies were withdrawn from Algeria and in the 3rd century AD, the Donatists, a North African Christian sect which had been suppressed by the Romans, declared a short-lived independent state. Algeria was invaded by the Vandals in the 5th century who occupied the country for a hundred years before being driven out by the Emperor Justinian's Byzantine army.
It was Justinian's aim to restore the Holy Roman Empire but the spread of Islam and the Arab conquest of North Africa during the 7th century thwarted the expansion of Byzantium and permanently changed the character of North Africa.
The Arab invasion was not without resistance. The Berbers, led by a tribal high priestess named Kahina who claimed conversion to Judaism, fought the invaders but eventually surrendered to the Umayyad Khalif. The Berbers quickly embraced Islam and, in the 8th century, formed their own Islamic government. Several tribes embraced Shi'ism and founded Shi'a tribal kingdoms, the most powerful of which was the Rustamid Kingdom at Tahert in central Algeria which flourished during the 8th and 9th centuries.
Algeria became part of the powerful Berber empires of the Almoravids and Almohads which dominated the Magreb and Andalusia. Tlemcen became the eastern capital of the Almohads and flourished as a centre of Islam. During this period Algerian seaports like Algiers, Annaba and Bijaya thrived on trade with European markets.