Algeria has been inhabited by Berbers (or Amazigh) since at least 10,000 BC. From 1000 BC on, the Carthaginians became an influence on them, establishing settlements along the coast. Berber kingdoms began to emerge, most notably Numidia, and seized the opportunity offered by the Punic Wars to become independent of Carthage, only to be taken over soon after by the Roman Republic in 200 BC.

As the Roman Empire collapsed, the Berbers became independent again in much of the area, while the Vandals took over parts until expelled by Justinian’s generals. The Byzantine Empire then retained a precarious grip on the east of the country until the coming of the Arabs in the 8th century.

After some decades of fierce resistance under leaders such as Kusayla and Kahina, the Berbers adopted Islam en masse, but almost immediately expelled the Caliphate from Algeria, establishing an Ibadi state under the Rustamids.

Having converted the Kutama of Kabylie to its cause, the Shia Fatimids overthrew the Rustamids, and conquered Egypt. They left Algeria and Tunisia to their Zirid vassals; when the latter rebelled and adopted Sunnism, they sent in a populous Arab tribe, the Banu Hilal, to weaken them, thus incidentally initiating the Arabization of the countryside.

The Almoravids and Almohads, Berber dynasties from the west founded by religious reformers, brought a period of relative peace and development; however, with the Almohads’ collapse, Algeria became a battleground for their three successor states, the Algerian Zayyanids, Tunisian Hafsids, and Moroccan Merinids. In the fifteenth and sixteenth centuries, Spain started attacking and taking over many coastal cities, prompting some to seek help from the Ottoman Empire.

Algeria was brought into the Ottoman Empire by Khair ad-Din and his brother Aruj, who established Algeria’s modern boundaries in the north and made its coast a base for the corsairs; their privateering peaked in Algiers in the 1600s. Piracy on American vessels in the Mediterranean resulted in the First and Second Barbary War with the United States.

On the pretext of a slight to their consul, the French invaded Algiers in 1830; however, intense resistance from such personalities as Emir Abdelkader made for a slow conquest of Algeria, not technically completed until the early 1900s when the last Tuareg were conquered.

Meanwhile, however, the French had made Algeria an integral part of France, a status that would end only with the collapse of the Fourth Republic. Tens of thousands of settlers from France, Italy, Spain, and Malta moved in to farm the Algerian coastal plain and occupy the most prized parts of Algeria’s cities, benefiting from the French government’s confiscation of communally held land.

People of European descent in Algeria (the so-called pieds-noirs), as well as the native Algerian Jews, were full French citizens starting from the end of the 19th century; by contrast, the vast majority of Muslim Algerians remained outside of French law, and possessed neither French citizenship nor the right to vote. Algeria’s social fabric was stretched to breaking point during this period: literacy dropped massively, while land confiscation uprooted much of the population.

In 1954, the National Liberation Front (FLN) launched the guerrilla Algerian War of Independence; after nearly a decade of urban and rural warfare, they succeeded in pushing the French out in 1962. Most of the 1,025,000 pieds-noirs, as well as 91,000 harkis (pro-French Muslim Algerians serving in the French Army), together forming about 10% of the population of Algeria in 1962, fled Algeria for France in just a few months in the middle of that year.

Algeria’s first president, the FLN leader Ahmed Ben Bella, was overthrown by his former ally and defense minister, Houari Boumdi nne in 1965. The country then enjoyed almost 25 years of relative stability under the one-party socialism of Boumedienne and his successors.

In the 1990s, Algeria was engulfed in a protracted and violent civil war after the military prevented an Islamist political party, the Islamic Salvation Front from taking power following the country’s first multiparty elections. More than 100,000 people were killed, often in unprovoked massacres of civilians by guerrilla groups such as the Armed Islamic Group.