History of Algeria

Much of the history of Algeria has taken place on the fertile coastal plain of North Africa, which is often called the Maghreb (or Maghreb). North Africa served as a transit region for people moving towards Europe or the Middle East, thus, the region's inhabitants have been influenced by populations from other areas, including the Carthaginians, Romans, and Vandals. The region was conquered by the Muslims in the early 8th century AD, but broke off from the Umayyad Caliphate after the Berber Revolt of 740. During the Ottoman period, Algeria became an important state in the Mediterranean sea which led to many naval conflicts. The last significant events in the country's recent history have been the Algerian War and Algerian Civil War.

Prehistory
Evidence of the early human occupation of Algeria is demonstrated by the discovery of 1.8 million year old Oldowan stone tools found at Ain Hanech in 1992. In 1954 fossilised Homo erectus bones were discovered by C. Arambourg at Ternefine that are 700,000 years old. Neolithic civilization (marked by animal domestication and subsistence agriculture) developed in the Saharan and Mediterranean Maghrib between 6000 and 2000 BC. This type of economy, richly depicted in the Tassili n'Ajjer cave paintings in southeastern Algeria, predominated in the Maghrib until the classical period.

Numidia
Numidia (Berber: Inumiden; 202–40 BC) was the ancient kingdom of the Numidians located in northwest Africa, initially comprising the territory that now makes up modern-day Algeria, but later expanding across what is today known as Tunisia, Libya, and some parts of Morocco. The polity was originally divided between the Massylii in the east and the Masaesyli in the west. During the Second Punic War (218–201 BC), Masinissa, king of the Massylii, defeated Syphax of the Masaesyli to unify Numidia into one kingdom. The kingdom began as a sovereign state and later alternated between being a Roman province and a Roman client state.

Numidia, at its largest extent, was bordered by Mauretania to the west, at the Moulouya River, Africa to the east (also exercising control over Tripolitania), the Mediterranean Sea to the north, and the Sahara to the south. It was one of the first major states in the history of Algeria and the Berbers.

War With Rome
By 112 BC, Jugurtha resumed his war with Adherbal. He incurred the wrath of Rome in the process by killing some Roman businessmen who were aiding Adherbal. After a brief war with Rome, Jugurtha surrendered and received a highly favourable peace treaty, which raised suspicions of bribery once more. The local Roman commander was summoned to Rome to face corruption charges brought by his political rival Gaius Memmius. Jugurtha was also forced to come to Rome to testify against the Roman commander, where Jugurtha was completely discredited once his violent and ruthless past became widely known, and after he had been suspected of murdering a Numidian rival.

War broke out between Numidia and the Roman Republic and several legions were dispatched to North Africa under the command of the Consul Quintus Caecilius Metellus Numidicus. The war dragged out into a long and seemingly endless campaign as the Romans tried to defeat Jugurtha decisively. Frustrated at the apparent lack of action, Metellus' lieutenant Gaius Marius returned to Rome to seek election as Consul. Marius was elected, and then returned to Numidia to take control of the war. He sent his Quaestor Sulla to neighbouring Mauretania in order to eliminate their support for Jugurtha. With the help of Bocchus I of Mauretania, Sulla captured Jugurtha and brought the war to a conclusive end. Jugurtha was brought to Rome in chains and was placed in the Tullianum.

Jugurtha was executed by the Romans in 104 BC, after being paraded through the streets in Gaius Marius' Triumph.

Independence
The Greek historians referred to these peoples as "Νομάδες" (i.e. Nomads), which by Latin interpretation became "Numidae" (but cf. also the correct use of Nomades). Historian Gabriel Camps, however, disputes this claim, favoring instead an African origin for the term.

The name appears first in Polybius (second century BC) to indicate the peoples and territory west of Carthage including the entire north of Algeria as far as the river Mulucha (Muluya), about 160 kilometres (100 mi) west of Oran.

The Numidians were composed of two great tribal groups: the Massylii in eastern Numidia, and the Masaesyli in the west. During the first part of the Second Punic War, the eastern Massylii, under their king Gala, were allied with Carthage, while the western Masaesyli, under king Syphax, were allied with Rome. The Kingdom of Masaesyli under Syphax extended from the Moulouya river to Oued Rhumel. However, in 206 BC, the new king of the eastern Massylii, Masinissa, allied himself with Rome, and Syphax of the Masaesyli switched his allegiance to the Carthaginian side. At the end of the war, the victorious Romans gave all of Numidia to Masinissa of the Massylii. At the time of his death in 148 BC, Masinissa's territory extended from the Moulouya to the boundary of the Carthaginian territory, and also southeast as far as Cyrenaica to the gulf of Sirte, so that Numidia entirely surrounded Carthage (Appian, Punica, 106) except towards the sea. Furthermore, after the capture of Syphax the king in modern day Morocco with his capital based in Tingis, Bokkar, had become a vassal of Massinissa. Massinissa had also penetrated as far south beyond the Atlas to the Gaetuli and Fezzan was part of his domain.

In 179 B.C. Masinissa had received a golden crown from the inhabitants of Delos as he had offered them a shipload of grain. A statue of Masinissa was set up in Delos in honour of him as well as an inscription dedicated to him in Delos by a native from Rhodes. His sons too had statues of them erected on the island of Delos and the King of Bithynia, Nicomedes, had also dedicated a statue to Masinissa.

After the death of the long-lived Masinissa around 148 BC, he was succeeded by his son Micipsa. When Micipsa died in 118 BC, he was succeeded jointly by his two sons Hiempsal I and Adherbal and Masinissa's illegitimate grandson, Jugurtha, who was very popular among the Numidians. Hiempsal and Jugurtha quarrelled immediately after the death of Micipsa. Jugurtha had Hiempsal killed, which led to open war with Adherbal.

Phoenician traders arrived on the North African coast around 900 BC and established Carthage (in present-day Tunisia) around 800 BC. During the classical period, 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, but territorial expansion also resulted in the enslavement or military recruitment of some Berbers and in the extraction of tribute from others.

The Carthaginian state declined because of successive defeats by the Romans in the Punic Wars, and in 146 BC, the city of Carthage was destroyed. As Carthaginian power waned, the influence of Berber leaders in the hinterland grew.

By the 2nd century BC, several large but loosely administered Berber kingdoms had emerged. After that, king Masinissa managed to unify Numidia under his rule.

Roman empire


Christianity arrived in the 2nd century. By the end of the 4th century, the settled areas had become Christianized, and some Berber tribes had converted en masse.

After the fall of the Western Roman Empire, Algeria came under the control of the Vandal Kingdom. Later, the Eastern Roman Empire (also known as the Byzantine Empire) conquered Algeria from the Vandals, incorporating it into the Praetorian prefecture of Africa and later the Exarchate of Africa.

Medieval Muslim Algeria
From the 8th century Umayyad conquest of North Africa led by Musa bin Nusayr, Arab colonization started. The 11th century invasion of migrants from the Arabian peninsula brought oriental tribal customs. The introduction of Islam and Arabic had a profound impact on North Africa. The new religion and language introduced changes in social and economic relations, and established links with the Arab world through acculturation and assimilation.

The second Arab military expeditions into the Maghreb, between 642 and 669, resulted in the spread of Islam. The Umayyads (a Muslim dynasty based in Damascus from 661 to 750) recognised that the strategic necessity of dominating the Mediterranean dictated a concerted military effort on the North African front. By 711 Umayyad forces helped by Berber converts to Islam had conquered all of North Africa. In 750 the Abbasids succeeded the Umayyads as Muslim rulers and moved the caliphate to Baghdad. Under the Abbasids, Berber Kharijites Sufri Banu Ifran were opposed to Umayyad and Abbasids. After, the Rustumids (761–909) actually ruled most of the central Maghrib from Tahirt, southwest of Algiers. The imams gained a reputation for honesty, piety, and justice, and the court of Tahirt was noted for its support of scholarship. The Rustumid imams failed, however, to organise a reliable standing army, which opened the way for Tahirt's demise under the assault of the Fatimid dynasty.

The Fatimids left the rule of most of Algeria to the Zirids and Hammadid (972–1148), a Berber dynasty that centered significant local power in Algeria for the first time, but who were still at war with Banu Ifran (kingdom of Tlemcen) and Maghraoua (942-1068). This period was marked by constant conflict, political instability, and economic decline. Following a large incursion of Arab Bedouin from Egypt beginning in the first half of the 11th century, the use of Arabic spread to the countryside, and sedentary Berbers were gradually Arabised.

The Almoravid ("those who have made a religious retreat") movement developed early in the 11th century among the Sanhaja Berbers of southern Morocco. The movement's initial impetus was religious, an attempt by a tribal leader to impose moral discipline and strict adherence to Islamic principles on followers. But the Almoravid movement shifted to engaging in military conquest after 1054. By 1106, the Almoravids had conquered the Maghreb as far east as Algiers and Morocco, and Spain up to the Ebro River.

Like the Almoravids, the Almohads ("unitarians") found their inspiration in Islamic reform. The Almohads took control of Morocco by 1146, captured Algiers around 1151, and by 1160 had completed the conquest of the central Maghrib. The zenith of Almohad power occurred between 1163 and 1199. For the first time, the Maghrib was united under a local regime, but the continuing wars in Spain overtaxed the resources of the Almohads, and in the Maghrib their position was compromised by factional strife and a renewal of tribal warfare.

In the central Maghrib, the Abdalwadid founded a dynasty that ruled the Kingdom of Tlemcen in Algeria. For more than 300 years, until the region came under Ottoman suzerainty in the 16th century, the Zayanids kept a tenuous hold in the central Maghrib. Many coastal cities asserted their autonomy as municipal republics governed by merchant oligarchies, tribal chieftains from the surrounding countryside, or the privateers who operated out of their ports. Nonetheless, Tlemcen, the "pearl of the Maghrib," prospered as a commercial center.

Berber dynasties
According to historians of the Middle Ages, the Berbers were divided into two branches, both going back to their ancestors Mazigh. The two branches, called Botr and Barnès were divided into tribes, and each Maghreb region is made up of several tribes. The large Berber tribes or peoples are Sanhaja, Houara, Zenata, Masmuda, Kutama, Awarba, Barghawata ... etc. Each tribe is divided into sub tribes. All these tribes had independent and territorial decisions.

Several Berber dynasties emerged during the Middle Ages: - In North and West Africa, in Spain (al-Andalus), Sicily, Egypt, as well as in the southern part of the Sahara, in modern-day Mali, Niger, and Senegal. The medieval historian Ibn Khaldun described the follying Berber dynasties: Zirid, Banu Ifran, Maghrawa, Almoravid, Hammadid, Almohad Caliphate, Marinid, Zayyanid, Wattasid, Meknes, Hafsid dynasty, Fatimids.

The invasion of the Banu Hilal Arab tribes in the 11th century sacked Kairouan, and the area under Zirid control was reduced to the coastal region, and the Arab conquests fragmented into petty Bedouin emirates.

Maghrawa Dynasty
The Maghrawa or Meghrawa (Arabic: المغراويون) were a large Zenata Berber tribal confederation whose cradle and seat of power was the territory located on the Chlef in the north-western part of today's Algeria, bounded by the Ouarsenis to the south, the Mediterranean Sea to the north and Tlemcen to the west. They ruled these areas on behalf of the Umayyad Caliphate of Cordoba at the end of the 10th century and during the first half of the 11th century. The Maghrawa confederation of zanata Berbers supposedly originated in the region of modern Algeria between Tlemcen and Tenes. The confederation of Maghrawa were the majority people of the central Maghreb among the Zenata (Gaetuli). Both nomadic and sedentary, the Maghrawa lived under the command of Maghrawa chiefs or Zenata. Algiers has been the territory of the Maghrawa since ancient times. The name Maghrawa was transcribed into Greek by historians. The great kingdom of the Maghrawa was located between Algiers, Cherchell, Ténès, Chlef, Miliana and Médéa. The Maghrawa imposed their domination in the Aurès. [when?] Chlef and its surroundings were populated by the Maghrawa according to Ibn Khaldun. The Maghrawa settled and extended their domination throughout the Dahra and beyond Miliana to the Tafna wadi near Tlemcen,[when?] and were found as far away as Mali.[citation needed]

The Maghrawa were one of the first Berber tribes to submit to Islam in the 7th century. They supported Uqba ibn Nafi in his campaign to the Atlantic in 683. They defected from Sunni Islam and became Kharijite Muslims from the 8th century, and allied first with the Idrisids, and, from the 10th century on, with the Umayyads of Córdoba in Al-Andalus. As a result, they were caught up in the Umayyad-Fatimid conflict in Morocco and Algeria. Although they won a victory over the allies of the Fatimids in 924, they soon allied with them. When they switched back to the side of Córdoba, the Zirids briefly took control over most of Morocco, and ruled on behalf of the Fatimids. In 976/977 the Maghrawa conquered Sijilmasa from the Banu Midrar, and in 980 were able to drive the Miknasa out of Sijilmasa as well.

The Maghrawa reached their peak under Ziri ibn Atiyya (to 1001), who achieved supremacy in Fez under Umayyad suzerainty, and expanded their territory at the expense of the Banu Ifran in the northern Maghreb – another Zenata tribe whose alliances had shifted often between the Fatimids and the Umayyads of Córdoba. Ziri ibn Atiyya conquered as much as he could of what is now northern Morocco and was able to achieve supremacy in Fez by 987. In 989 he defeated his enemy, Abu al-Bahār, which resulted in Ziri ruling from Zab to Sous Al-Aqsa, in 991 achieving supremacy in the western Maghreb. As a result of his victory he was invited to Córdoba by Ibn Abi 'Amir al-Mansur (also Latinized as Almanzor), the regent of Caliph Hisham II and de facto ruler of the Caliphate of Córdoba. Ziri brought many gifts and Al-Mansur housed him in a lavish palace, but Ziri soon returned to North Africa. The Banu Ifran took advantage of his absence and, under Yaddū, managed to capture Fez. [full citation needed] After a bloody struggle, Ziri reconquered Fez in 993 and displayed Yaddū's severed head on its walls.[citation needed]

A period of peace followed, in which Ziri founded the city of Oujda in 994 and made it his capital. However, Ziri was loyal to the Umayyad caliphs in Cordoba and increasingly resented the way that Ibn Abi 'Amir was holding Hisham II captive while progressively usurping his power. In 997 Ziri rejected Ibn Abi 'Amir's authority and declared himself a direct supporter of Caliph Hisham II. Ibn Abi 'Amir sent an invasion force to Morocco. After three unsuccessful months, Ibn Abi 'Amir's army was forced to retreat to the safety of Tangiers, so Ibn Abi 'Amir sent a powerful reinforcements under his son Abd al-Malik.[citation needed] The armies clashed near Tangiers, and in this battle, Ziri was stabbed by an African soldier who reported to Abd al-Malik that he had seriously wounded the Zenata leader. Abd al-Malik pressed home the advantage, and the wounded Ziri fled, hotly pursued by the Caliph's army. The inhabitants of Fez would not let him enter the city, but opened the gates to Abd al-Malik on 13 October 998. Ziri fled to the Sahara, where he rallied the Zenata tribes and overthrew the unpopular remnants of the Idrisid dynasty at Tiaret. He was able to expand his territory to include Tlemcen and other parts of western Algeria, this time under Fatimid protection. Ziri died in 1001 of the after-effects of the stab wounds. He was succeeded by his son Al-Mu'izz, who made peace with Al-Mansur, and regained possession of all his father's former territories.[citation needed]

A revolt against the Andalusian Umayyads was put down by Ibn Abi 'Amir, although the Maghrawa were able to regain power in Fez. Under the succeeding rulers al-Muizz (1001–1026), Hamman (1026–1039) and Dunas (1039), they consolidated their rule in northern and central Morocco.[citation needed]

Internal power struggles after 1060 enabled the Almoravid dynasty to conquer the Maghrawa realm in 1070 and put an end to their rule. In the mid 11th century the Maghrawa still controlled most of Morocco, notably most of the Sous and Draa River area as well as Aghmat, Fez and Sijilmasa. Later, Zenata power declined. The Maghrawa and Banu Ifran began oppressing their subjects, shedding their blood, violating their women, breaking into homes to seize food and depriving traders of their goods. Anyone who tried to ward them off was killed.

Zirid Dynasty
The Zirid dynasty (الزيريون), Banu Ziri (بنو زيري), or the Zirid state (الدولة الزيرية) was a Sanhaja Berber dynasty from modern-day Algeria which ruled the central Maghreb from 972 to 1014 and Ifriqiya (eastern Maghreb) from 972 to 1148.

Descendants of Ziri ibn Manad, a military leader of the Fatimid Caliphate and the eponymous founder of the dynasty, the Zirids were emirs who ruled in the name of the Fatimids. The Zirids gradually established their autonomy in Ifriqiya through military conquest until officially breaking with the Fatimids in the mid-11th century. The rule of the Zirid emirs opened the way to a period in North African history where political power was held by Berber dynasties such as the Almoravid dynasty, Almohad Caliphate, Zayyanid dynasty, Marinid Sultanate and Hafsid dynasty.

Under Buluggin ibn Ziri the Zirids extended their control westwards and briefly occupied Fez and much of present-day Morocco after 980, but encountered resistance from the local Zenata Berbers who gave their allegiance to the Caliphate of Cordoba. To the east, Zirid control was extended over Tripolitania after 978 and as far as Ajdabiya (in present-day Libya). One member of the dynastic family, Zawi ibn Ziri, revolted and fled to al-Andalus, eventually founding the Taifa of Granada in 1013, after the collapse of the Caliphate of Cordoba. Another branch of the Zirids, the Hammadids, broke away from the main branch after various internal disputes and took control of the territories of the central Maghreb after 1015. The Zirids proper were then designated as Badicides and occupied only Ifriqiya between 1048 and 1148. They were based in Kairouan until 1057, when they moved the capital to Mahdia on the coast. The Zirids of Ifriqiya also intervened in Sicily during the 11th century, as the Kalbids, the dynasty who governed the island on behalf of the Fatimids, fell into disorder.

The Zirids of Granada surrendered to the Almoravids in 1090, but the Badicides and the Hammadids remained independent during this time. Sometime between 1041 and 1051 the Zirid ruler al-Mu'izz ibn Badis renounced the Fatimid Caliphs and recognized the Sunni Muslim Abbasid Caliphate. In retaliation, the Fatimids instigated the migration of the Banu Hilal tribe to the Maghreb, dealing a serious blow to Zirid power in Ifriqiya. In the 12th century, the Hilalian invasions combined with the attacks of the Normans of Sicily along the coast further weakened Zirid power. The last Zirid ruler, al-Hasan, surrendered Mahdia to the Normans in 1148, thus ending independent Zirid rule. The Almohad Caliphate conquered the central Maghreb and Ifriqiya by 1160, ending the Hammadid dynasty in turn and finally unifying the whole of the Maghreb.

Origins and establishment
The Zirids were Sanhaja Berbers, from the sedentary Talkata tribe, originating from the area of modern Algeria. In the 10th century this tribe served as vassals of the Fatimid Caliphate, an Isma'ili Shi'a state that challenged the authority of the Sunni Abbasid caliphs. The progenitor of the Zirid dynasty, Ziri ibn Manad (r. 935–971) was installed as governor of the central Maghreb (roughly north-eastern Algeria today) on behalf of the Fatimids, guarding the western frontier of the Fatimid Caliphate. With Fatimid support Ziri founded his own capital and palace at 'Ashir, south-east of Algiers, in 936. He proved his worth as a key ally in 945, during the Kharijite rebellion of Abu Yazid, when he helped break Abu Yazid's siege of the Fatimid capital, Mahdia. After playing this valuable role, he expanded 'Ashir with a new palace circa 947. In 959 he aided Jawhar al-Siqili on a Fatimid military expedition which successfully conquered Fez and Sijilmasa in present-day Morocco. On their return home to the Fatimid capital they paraded the emir of Fez and the “Caliph” Ibn Wasul of Sijilmasa in cages in a humiliating manner. After this success, Ziri was also given Tahart to govern on behalf of the Fatimids. He was eventually killed in battle against the Zanata in 971.

When the Fatimids moved their capital to Egypt in 972, Ziri's son Buluggin ibn Ziri (r. 971–984) was appointed viceroy of Ifriqiya. He soon led a new expedition west and by 980 he had conquered Fez and most of Morocco, which had previously been retaken by the Umayyads of Cordoba in 973. He also led a successful expedition to Barghawata territory, from which he brought back a large number of slaves to Ifriqiya. In 978 the Fatimids also granted Buluggin overlordship of Tripolitania (in present-day Libya), allowing him to appoint his own governor in Tripoli. In 984 Buluggin died in Sijilmasa from an illness and his successor decided to abandon Morocco in 985.

Buluggin's successors and the first divisions
After Buluggin's death, rule of the Zirid state passed to his son, Al-Mansur ibn Buluggin (r. 984–996), and continued through his descendants. However, this alienated the other sons of Ziri ibn Manad who now found themselves excluded from power. In 999 many of these brothers launched a rebellion in 'Ashir against Badis ibn al-Mansur (r. 996–1016), Buluggin's grandson, marking the first serious break in the unity of the Zirids. The rebels were defeated in battle by Hammad ibn Buluggin, Badis' uncle, and most of the brothers were killed. The only remaining brother of stature, Zawi ibn Ziri, led the remaining rebels westwards and sought new opportunity in al-Andalus under the Umayyads Caliphs of Cordoba, the former enemies of the Fatimids and Zirids. He and his followers eventually founded an independent kingdom in al-Andalus, the Taifa of Granada, in 1013.

After 1001 Tripolitania broke away under the leadership of Fulful ibn Sa'id ibn Khazrun, a Maghrawa leader who founded the Banu Khazrun dynasty, which endured until 1147. Fulful fought a protracted war against Badis ibn al-Mansur and sought outside help from the Fatimids and even from the Umayyads of Cordoba, but after his death in 1009 the Zirids were able to retake Tripoli for a time. The region nonetheless remained effectively under control of the Banu Khazrun, who fluctuated between practical autonomy and full independence, often playing the Fatimids and the Zirids against each other. The Zirids finally lost Tripoli to them in 1022.

Badis appointed Hammad ibn Buluggin as governor of 'Ashir and the western Zirid territories in 997. He gave Hammad a great deal of autonomy, allowing him to campaign against the Zanata and control any new territories he conquered. Hammad constructed his own capital, the Qal'at Bani Hammad, in 1008, and in 1015 he rebelled against Badis and declared himself independent altogether, while also recognizing the Abbasids instead of the Fatimids as caliphs. Badis besieged Hammad's capital and nearly subdued him, but died in 1016 shortly before this could be accomplished. His son and successor, al-Mu'izz ibn Badis (r. 1016–1062), defeated Hammad in 1017, which forced the negotiation of a peace agreement between them. Hammad resumed his recognition of the Fatimids as caliphs but remained independent, forging a new Hammadid state which controlled a large part of present-day Algeria thereafter.

Apogee in Ifriqiya
The Zirid period of Ifriqiya is considered a high point in its history, with agriculture, industry, trade and learning, both religious and secular, all flourishing, especially in their capital, Qayrawan (Kairouan). The early reign of al-Mu'izz ibn Badis (r. 1016–1062) was particularly prosperous and marked the height of their power in Ifriqiya. In the eleventh century, when the question of Berber origin became a concern, the dynasty of al-Mu'izz started, as part of the Zirids' propaganda, to emphasize its supposed links to the Himyarite kings as a title to nobility, a theme that was taken the by court historians of the period. Management of the area by later Zirid rulers was neglectful as the agricultural economy declined, prompting an increase in banditry among the rural population. The relationship between the Zirids their Fatimid overlords varied - in 1016 thousands of Shiites died in rebellions in Ifriqiya, and the Fatimids encouraged the defection of Tripolitania from the Zirids, but nevertheless the relationship remained close. In 1049 the Zirids broke away completely by adopting Sunni Islam and recognizing the Abbasids of Baghdad as rightful Caliphs, a move which was popular with the urban Arabs of Kairouan.

In Sicily the Kalbids continued to govern on behalf of the Fatimids but the island descended into political disarray during the 11th century, inciting the Zirids to intervene on the island. In 1025 (or 1021 ), al-Mu'izz ibn Badis sent a fleet of 400 ships to the island in response to the Byzantines reconquering Calabria (in southern Italy) from the Muslims, but the fleet was lost in a powerful storm off the coast of Pantelleria. In 1036, the Muslim population of the island request aid from al-Mu'izz to overthrow the Kalbid emir Ahmad ibn Yusuf al-Akhal, whose rule they considered flawed and unjust. The request also contained a pledge to recognize al-Mu'izz as their ruler. Al-Mu'izz, eager to expand his influence after the fragmentation of Zirid North Africa, accepted and sent his son, 'Abdallah, to the island with a large army. Al-Akhal, who had been in negotiations with the Byzantines, requested help from them. A Byzantine army intervened and defeated the Zirid army on the island, but it then withdrew to Calabria, allowing 'Abdallah to finish off al-Akhal. Al-Akhal was besieged in Palermo and killed in 1038. 'Abdallah was subsequently forced to withdraw from the island, either due to the ever-divided Sicilians turning against him or due to another Byzantine invasion in 1038, led by George Maniakes. Another Kalbid amir, al-Hasan al-Samsam, was elected to govern Sicily, but Muslim rule there disintegrated into various petty factions leading up to the Norman conquest of the island in the second half of the 11th century.

Hilalian invasions and withdrawal to Mahdia
The Zirids renounced the Fatimids and recognized the Abbasid Caliphs in 1048-49, or sometime between 1041 and 1051. In retaliation, the Fatimids sent the Arab tribes of the Banu Hilal and the Banu Sulaym to the Maghreb. The Banu Sulaym settled first in Cyrenaica, but the Banu Hilal continued towards Ifriqiya. The Zirids attempted to stop their advance towards Ifriqiya, they sent 30,000 Sanhaja cavalry to meet the 3,000 Arab cavalry of Banu Hilal in the Battle of Haydaran of 14 April 1052. Nevertheless, the Zirids were decisively defeated and were forced to retreat, opening the road to Kairouan for the Hilalian Arab cavalry. The resulting anarchy devastated the previously flourishing agriculture, and the coastal towns assumed a new importance as conduits for maritime trade and bases for piracy against Christian shipping, as well as being the last holdout of the Zirids. The Banu Hilal invasions eventually forced al-Mu'izz ibn Badis to abandon Kairouan in 1057 and move his capital to Mahdia, while the Banu Hilal largely roamed and pillaged the interior of the former Zirid territories.

As a result of the Zirid withdrawal, various local principalities emerged in different areas. In Tunis, the shaykhs of the city elected Abd al-Haqq ibn Abd al-Aziz ibn Khurasan (r. 1059-1095) as local ruler. He founded the local Banu Khurasan dynasty that governed the city thereafter, alternately recognizing the Hammadids or the Zirids as overlords depending on the circumstances. In Qabis (Gabès), the Zirid governor, al-Mu'izz ibn Muhammad ibn Walmiya remained loyal until 1062 when, outraged by the expulsion of his two brothers from Mahdia by al-Mu'izz ibn Badis, he declared his independence and placed himself under the protection of Mu'nis ibn Yahya, a chief of Banu Hilal. Sfaqus (Sfax) was declared independent by the Zirid governor, Mansur al-Barghawati, who was murdered and succeeded by his cousin Hammu ibn Malil al-Barghawati.

Al-Mui'zz ibn Badis was succeeded by his son, Tamim ibn al-Mu'izz (r. 1062-1108), who spent much of his reign attempting to restore Zirid power in the region. In 1063 he repelled a siege of Mahdia by the independent ruler of Sfax while also capturing the important port of Sus (Sousse). Meanwhile, the Hammadid ruler al-Nasir ibn 'Alannas (r. 1062-1088) began to intervene in Ifriqiya around this time, having his sovereignty recognized in Sfax, Tunis, and Kairouan. Tamim organized a coalition with some of the Banu Hilal and Banu Sulaym tribes and succeeded in inflicting a heavy defeat on al-Nasir at the Battle of Sabiba in 1065. The war between the Zirids and Hammadids continued until 1077, when a truce was negotiated, sealed by a marriage between Tamim and one of al-Nasir's daughters. In 1074 Tamim sent a naval expedition to Calabria where they ravaged the Italian coasts, plundered Nicotera and enslaved many of its inhabitants. The next year (1075) another Zirid raid resulted in the capture of Mazara in Sicily; however, the Zirid emir rethought his involvement in Sicily and decided to withdraw, abandoning what they had briefly held. In 1087, the Zirid capital, Mahdia, was sacked by the Pisans. According to Ettinghausen, Grabar, and Jenkins-Madina, the Pisa Griffin is believed to have been part of the spoils taken during the sack. In 1083 Mahdia was besieged by a chief of the Banu Hilal, Malik ibn 'Alawi. Unable to take the city, Malik instead turned to Kairouan and captured that city, but Tamim marched out with his entire army and defeated the Banu Hilal forces, at which point he also brought Kairouan back under Zirid control. He went on to capture Gabès in 1097 and Sfax in 1100. Gabès, however, soon declared itself independent again under the leadership of the Banu Jami', a family from the Riyahi branch of the Banu Hilal.

Tamim's son and successor, Yahya ibn Tamim (r. 1108-1116), formally recognized the Fatimid caliphs again and received an emissary from Cairo in 1111. He captured an important fortress near Carthage called Iqlibiya and his fleet launched raids against Sardinia and Genoa, bringing back many captives. He was assassinated in 1116 and succeeded by his son, 'Ali ibn Yahya (r. 1116-1121). 'Ali continued to recognize the Fatimids, receiving another embassy from Cairo in 1118. He imposed his authority on Tunis, but failed to recapture Gabès from its local ruler, Rafi' ibn Jami', whose counterattack he then had to repel from Mahdia. He was succeeded by his son al-Hasan in 1121, the last Zirid ruler.

End of Zirid rule
During the 1130s and 1140s the Normans of Sicily began to capture cities and islands along the coast of Ifriqiya. Jerba was captured in 1135 and Tripoli was captured in 1146. In 1148, the Normans captured Sfax, Gabès, and Mahdia. In Mahdia, the population was weakened by years of famine and the bulk of the Zirid army was away on another campaign when the Norman fleet, commanded by George of Antioch, arrived off the coast. Al-Hasan decided to abandon the city, leaving it to be occupied, which effectively ended the Zirid dynasty's rule. Al-Hasan fled to the citadel of al-Mu'allaqa near Carthage and stayed there for a several months. He planned to flee to the Fatimid court in Egypt but the Norman fleet blocked his way, so instead he headed west, making for the Almohad court of 'Abd al-Mu'min in Marrakesh. He obtained permission from Yahya ibn al-'Aziz, the Hammadid ruler, to cross his territory, but after entering Hammadid territory he was detained and placed under house arrest in Algiers. When 'Abd al-Mu'min captured Algiers in 1151, he freed al-Hasan, who accompanied him back to Marrakesh. Later, when 'Abd al-Mu'min conquered Mahdia in 1160, placing all of Ifriqiya under Almohad rule, al-Hasan was with him. 'Abd al-Mu'min appointed him governor of Mahdia, where he remained, residing in the suburb of Zawila, until 'Abd al-Mu'min's death in 1163. The new Almohad caliph, Abu Ya'qub Yusuf, subsequently ordered him to come back to Marrakesh, but al-Hasan died along the way in Tamasna in 1167.

Hammadid Dynasty
The Hammadid dynasty (Arabic: الحمّاديون) was a branch of the Sanhaja Berber dynasty that ruled an area roughly corresponding to north-eastern modern Algeria between 1008 and 1152. The state reached its peak under Nasir ibn Alnas during which it was briefly the most important state in Northwest Africa.

The Hammadid dynasty's first capital was at Qalaat Beni Hammad. It was founded in 1007, and is now a UNESCO World Heritage Site. When the area was sacked by the Banu Hilal tribe, the Hammadids moved their capital to Béjaïa in 1090.

Almohad Caliphate
The Almohad Caliphate (خِلَافَةُ ٱلْمُوَحِّدِينَ or دَوْلَةُ ٱلْمُوَحِّدِينَ or ٱلدَّوْلَةُ ٱلْمُوَحِّدِيَّةُ from

ٱلْمُوَحِّدُونَ ) was a North African Berber Muslim empire founded in the 12th century. At its height, it controlled much of the Iberian Peninsula (Al Andalus) and North Africa (the Maghreb).

The Almohad docrtine was founded by Ibn Tumart among the Berber Masmuda tribes, but the Almohad caliphate and its ruling dynasty were founded after his death by Abd al-Mu'min al-Gumi,  which was born in the Hammadid region of Tlemcen, Algeria. Around 1120, Ibn Tumart first established a Berber state in Tinmel in the Atlas Mountains. Under Abd al-Mu'min (r. 1130–1163) they succeeded in overthrowing the ruling Almoravid dynasty governing Morocco in 1147, when he conquered Marrakesh and declared himself caliph. They then extended their power over all of the Maghreb by 1159. Al-Andalus soon followed, and all of Muslim Iberia was under Almohad rule by 1172.

The turning point of their presence in the Iberian Peninsula came in 1212, when Muhammad III, "al-Nasir" (1199–1214) was defeated at the Battle of Las Navas de Tolosa in the Sierra Morena by an alliance of the Christian forces from Castile, Aragon and Navarre. Much of the remaining territories of al-Andalus were lost in the ensuing decades, with the cities of Córdoba and Seville falling to the Christians in 1236 and 1248 respectively.

The Almohads continued to rule in Africa until the piecemeal loss of territory through the revolt of tribes and districts enabled the rise of their most effective enemies, the Marinids, from northern Morocco in 1215. The last representative of the line, Idris al-Wathiq, was reduced to the possession of Marrakesh, where he was murdered by a slave in 1269; the Marinids seized Marrakesh, ending the Almohad domination of the Western Maghreb.

Origins
The Almohad movement originated with Ibn Tumart, a member of the Masmuda, a Berber tribal confederation of the Atlas Mountains of southern Morocco. At the time, Morocco, western Algeria and Spain (al-Andalus), were under the rule of the Almoravids, a Sanhaja Berber dynasty. Early in his life, Ibn Tumart went to Spain to pursue his studies, and thereafter to Baghdad to deepen them. In Baghdad, Ibn Tumart attached himself to the theological school of al-Ash'ari, and came under the influence of the teacher al-Ghazali. He soon developed his own system, combining the doctrines of various masters. Ibn Tumart's main principle was a strict unitarianism (tawhid), which denied the independent existence of the attributes of God as being incompatible with His unity, and therefore a polytheistic idea. Ibn Tumart represented a revolt against what he perceived as anthropomorphism in Muslim orthodoxy. His followers would become known as the al-Muwaḥḥidūn ("Almohads"), meaning those who affirm the unity of God.

After his return to the Maghreb c. 1117, Ibn Tumart spent some time in various Ifriqiyan cities, preaching and agitating, heading riotous attacks on wine-shops and on other manifestations of laxity. He laid the blame for the latitude on the ruling dynasty of the Almoravids, whom he accused of obscurantism and impiety. He also opposed their sponsorship of the Maliki school of jurisprudence, which drew upon consensus (ijma) and other sources beyond the Qur'an and Sunnah in their reasoning, an anathema to the stricter Zahirism favored by Ibn Tumart. His antics and fiery preaching led fed-up authorities to move him along from town to town. After being expelled from Bejaia, Ibn Tumart set up camp in Mellala, in the outskirts of the city, where he received his first disciples – notably, al-Bashir (who would become his chief strategist) and Abd al-Mu'min (a Zenata Berber, who would later become his successor).

In 1120, Ibn Tumart and his small band of followers proceeded to Morocco, stopping first in Fez, where he briefly engaged the Maliki scholars of the city in debate. He even went so far as to assault the sister of the Almoravid emir ʿAli ibn Yusuf, in the streets of Fez, because she was going about unveiled, after the manner of Berber women. After being expelled from Fez, he went to Marrakesh, where he successfully tracked down the Almoravid emir Ali ibn Yusuf at a local mosque, and challenged the emir, and the leading scholars of the area, to a doctrinal debate. After the debate, the scholars concluded that Ibn Tumart's views were blasphemous and the man dangerous, and urged him to be put to death or imprisoned. But the emir decided merely to expel him from the city.

Ibn Tumart took refuge among his own people, the Hargha, in his home village of Igiliz (exact location uncertain), in the Sous valley. He retreated to a nearby cave, and lived out an ascetic lifestyle, coming out only to preach his program of puritan reform, attracting greater and greater crowds. At length, towards the end of Ramadan in late 1121, after a particularly moving sermon, reviewing his failure to persuade the Almoravids to reform by argument, Ibn Tumart 'revealed' himself as the true Mahdi, a divinely guided judge and lawgiver, and was recognized as such by his audience. This was effectively a declaration of war on the Almoravid state.

On the advice of one of his followers, Omar Hintati, a prominent chieftain of the Hintata, Ibn Tumart abandoned his cave in 1122 and went up into the High Atlas, to organize the Almohad movement among the highland Masmuda tribes. Besides his own tribe, the Hargha, Ibn Tumart secured the adherence of the Ganfisa, the Gadmiwa, the Hintata, the Haskura, and the Hazraja to the Almohad cause. Around 1124, Ibn Tumart erected the ribat of Tinmel, in the valley of the Nfis in the High Atlas, an impregnable fortified complex, which would serve both as the spiritual center and military headquarters of the Almohad movement.

For the first eight years, the Almohad rebellion was limited to a guerilla war along the peaks and ravines of the High Atlas. Their principal damage was in rendering insecure (or altogether impassable) the roads and mountain passes south of Marrakesh – threatening the route to all-important Sijilmassa, the gateway of the trans-Saharan trade. Unable to send enough manpower through the narrow passes to dislodge the Almohad rebels from their easily defended mountain strong points, the Almoravid authorities reconciled themselves to setting up strongholds to confine them there (most famously the fortress of Tasghîmût that protected the approach to Aghmat, which was conquered by the Almohads in 1132 ), while exploring alternative routes through more easterly passes.

Ibn Tumart organized the Almohads as a commune, with a minutely detailed structure. At the core was the Ahl ad-dār ("House of the Mahdi:), composed of Ibn Tumart's family. This was supplemented by two councils: an inner Council of Ten, the Mahdi's privy council, composed of his earliest and closest companions; and the consultative Council of Fifty, composed of the leading sheikhs of the Masmuda tribes. The early preachers and missionaries (ṭalaba and huffāẓ) also had their representatives. Militarily, there was a strict hierarchy of units. The Hargha tribe coming first (although not strictly ethnic; it included many "honorary" or "adopted" tribesmen from other ethnicities, e.g. Abd al-Mu'min himself). This was followed by the men of Tinmel, then the other Masmuda tribes in order, and rounded off by the black fighters, the ʻabīd. Each unit had a strict internal hierarchy, headed by a mohtasib, and divided into two factions: one for the early adherents, another for the late adherents, each headed by a mizwar (or amzwaru); then came the sakkakin (treasurers), effectively the money-minters, tax-collectors, and bursars, then came the regular army (jund), then the religious corps – the muezzins, the hafidh and the hizb – followed by the archers, the conscripts, and the slaves. Ibn Tumart's closest companion and chief strategist, al-Bashir, took upon himself the role of "political commissar", enforcing doctrinal discipline among the Masmuda tribesmen, often with a heavy hand.

In early 1130, the Almohads finally descended from the mountains for their first sizeable attack in the lowlands. It was a disaster. The Almohads swept aside an Almoravid column that had come out to meet them before Aghmat, and then chased their remnant all the way to Marrakesh. They laid siege to Marrakesh for forty days until, in April (or May) 1130, the Almoravids sallied from the city and crushed the Almohads in the bloody Battle of al-Buhayra (named after a large garden east of the city). The Almohads were thoroughly routed, with huge losses. Half their leadership was killed in action, and the survivors only just managed to scramble back to the mountains.

Ibn Tumart died shortly after, in August 1130. That the Almohad movement did not immediately collapse after such a devastating defeat and the death of their charismatic Mahdi, is likely due to the skills of his successor, Abd al-Mu'min. Ibn Tumart's death was kept a secret for three years, a period which Almohad chroniclers described as a ghayba or "occultation". This period likely gave Abd al-Mu'min time to secure his position as successor to the political leadership of the movement. Although a Zenata Berber from Tagra (Algeria), and thus an alien among the Masmuda of southern Morocco, Abd al-Mu'min nonetheless saw off his principal rivals and hammered wavering tribes back to the fold. In an ostentatious gesture of defiance, in 1132, if only to remind the emir that the Almohads were not finished, Abd al-Mu'min led an audacious night operation that seized Tasghîmût fortress and dismantled it thoroughly, carting off its great gates back to Tinmel. Three years after Ibn Tumart's death he was officially proclaimed "Caliph".

In order to neutralise the Masmudas, to whom he was a stranger, Abd al-Mumin relied on his tribe of origin, the Kumiyas (a Berber tribe from Orania), which he integrated massively into the army and within the Almohad power. He thus appointed his son as his successor and his other children as governors of the provinces of the Caliphate. The Kumiyas would later form the bodyguard of Abd al Mumin and his successor. In addition, he also relied on Arabs, representatives of the great Hilalian families, whom he deported to Morocco to weaken the influence of the Masmuda sheikhs. These moves have the effect of advancing the Arabisation of the future Morocco.

Al-Andalus
Abd al-Mu'min then came forward as the lieutenant of the Mahdi Ibn Tumart. Between 1130 and his death in 1163, Abd al-Mu'min not only rooted out the Almoravids, but extended his power over all northern Africa as far as Egypt, becoming amir of Marrakesh in 1147.

Al-Andalus followed the fate of Africa. Between 1146 and 1173, the Almohads gradually wrested control from the Almoravids over the Moorish principalities in Iberia. The Almohads transferred the capital of Muslim Iberia from Córdoba to Seville. They founded a great mosque there; its tower, the Giralda, was erected in 1184 to mark the accession of Ya'qub I. The Almohads also built a palace there called Al-Muwarak on the site of the modern day Alcázar of Seville. The Almohad princes had a longer and more distinguished career than the Almoravids. The successors of Abd al-Mumin, Abu Yaqub Yusuf (Yusuf I, ruled 1163–1184) and Abu Yusuf Yaqub al-Mansur (Yaʻqūb I, ruled 1184–1199), were both able men. Initially their government drove many Jewish and Christian subjects to take refuge in the growing Christian states of Portugal, Castile, and Aragon. Ultimately they became less fanatical than the Almoravids, and Ya'qub al-Mansur was a highly accomplished man who wrote a good Arabic style and protected the philosopher Averroes. In 1190–1191, he campaigned in southern Portugal and won back territory lost in 1189. His title of "al-Manṣūr" ("the Victorious") was earned by his victory over Alfonso VIII of Castile in the Battle of Alarcos (1195).

From the time of Yusuf II, however, the Almohads governed their co-religionists in Iberia and central North Africa through lieutenants, their dominions outside Morocco being treated as provinces. When Almohad emirs crossed the Straits it was to lead a jihad against the Christians and then return to Morocco.

Holding years
In 1212, the Almohad Caliph Muhammad 'al-Nasir' (1199–1214), the successor of al-Mansur, after an initially successful advance north, was defeated by an alliance of the four Christian kings of Castile, Aragón, Navarre, and Portugal, at the Battle of Las Navas de Tolosa in the Sierra Morena. The battle broke the Almohad advance, but the Christian powers remained too disorganized to profit from it immediately.

Before his death in 1213, al-Nasir appointed his young ten-year-old son as the next caliph Yusuf II "al-Mustansir". The Almohads passed through a period of effective regency for the young caliph, with power exercised by an oligarchy of elder family members, palace bureaucrats and leading nobles. The Almohad ministers were careful to negotiate a series of truces with the Christian kingdoms, which remained more-or-less in place for next fifteen years (the loss of Alcácer do Sal to the Kingdom of Portugal in 1217 was an exception).

In early 1224, the youthful caliph died in an accident, without any heirs. The palace bureaucrats in Marrakesh, led by the wazir Uthman ibn Jam'i, quickly engineered the election of his elderly grand-uncle, Abd al-Wahid I 'al-Makhlu', as the new Almohad caliph. But the rapid appointment upset other branches of the family, notably the brothers of the late al-Nasir, who governed in al-Andalus. The challenge was immediately raised by one of them, then governor in Murcia, who declared himself Caliph Abdallah al-Adil. With the help of his brothers, he quickly seized control of al-Andalus. His chief advisor, the shadowy Abu Zayd ibn Yujjan, tapped into his contacts in Marrakesh, and secured the deposition and assassination of Abd al-Wahid I, and the expulsion of the al-Jami'i clan.

This coup has been characterized as the pebble that finally broke al-Andalus. It was the first internal coup among the Almohads. The Almohad clan, despite occasional disagreements, had always remained tightly knit and loyally behind dynastic precedence. Caliph al-Adil's murderous breach of dynastic and constitutional propriety marred his acceptability to other Almohad sheikhs. One of the recusants was his cousin, Abd Allah al-Bayyasi ("the Baezan"), the Almohad governor of Jaén, who took a handful of followers and decamped for the hills around Baeza. He set up a rebel camp and forged an alliance with the hitherto quiet Ferdinand III of Castile. Sensing his greater priority was Marrakesh, where recusant Almohad sheikhs had rallied behind Yahya, another son of al-Nasir, al-Adil paid little attention to this little band of misfits.

Zayyanid Dynasty
The Kingdom of Tlemcen or Zayyanid Kingdom of Tlemcen (الزيانيون) was a Berber kingdom in what is now the northwest of Algeria. Its territory stretched from Tlemcen to the Chelif bend and Algiers, and at its zenith reached Sijilmasa and the Moulouya River in the west, Tuat to the south and the Soummam in the east.

The Tlemcen Kingdom was established after the demise of the Almohad Caliphate in 1236, and later fell under Ottoman rule in 1554. It was ruled by sultans of the Zayyanid dynasty. The capital of the Tlemcen kingdom centred on Tlemcen, which lay on the primary east–west route between Morocco and Ifriqiya. The kingdom was situated between the realm of the Marinids the west, centred on Fez, and the Hafsids to the east, centred on Tunis.

Tlemcen was a hub for the north–south trade route from Oran on the Mediterranean coast to the Western Sudan. As a prosperous trading centre, it attracted its more powerful neighbours. At different times the kingdom was invaded and occupied by the Marinids from the west, by the Hafsids from the east, and by Aragonese from the north. At other times, they were able to take advantage of turmoil among their neighbours: during the reign of Abu Tashfin I (r. 1318–1337) the Zayyanids occupied Tunis and in 1423, under the reign of Abu Malek, they briefly captured Fez. In the south the Zayyanid realm included Tuat, Tamentit and the Draa region which was governed by Abdallah Ibn Moslem ez Zerdali, a sheikh of the Zayyanids.

Rise to power (13th century)
The Bānu ʿabd āl-Wād, also called the Bānu Ziyān or Zayyanids after Yaghmurasen Ibn Zyan, the founder of the dynasty, were leaders of a Berber group who had long been settled in the Central Maghreb. Although contemporary chroniclers asserted that they had a noble Arab origin, he reportedly spoke in Zenati dialect and denied the lineage that genealogists had attributed to him. The town of Tlemcen, called Pomaria by the Romans, is about 806m above sea level in fertile, well-watered country.

Tlemcen was an important centre under the Almoravid dynasty and its successors the Almohad Caliphate, who began a new wall around the town in 1161.

Yaghmurasen ibn Zayyan (1235–83) of the Bānu ʿabd āl-Wād was governor of Tlemcen under the Almohads. He inherited leadership of the family from his brother in 1235. When the Almohad empire began to fall apart, in 1235, Yaghmurasen declared his independence. The city of Tlemcen became the capital of one of three successor states, ruled for centuries by successive Ziyyanid sultans. Its flag was a white crescent pointing upwards on a blue field. The kingdom covered the less fertile regions of the Tell Atlas. Its people included a minority of settled farmers and villagers, and a majority of nomadic herders.

Yaghmurasen was able to maintain control over the rival Berber groups, and when faced with the outside threat of the Marinid dynasty, he formed an alliance with the Emir of Granada and the King of Castile, Alfonso X. According to Ibn Khaldun, "he was the bravest, most dreaded and honourable man of the 'Abd-la-Wadid family. No one looked after the interest of his people, maintained the influence of the kingdom and managed the state administration better than he did." In 1248 he defeated the Almohad Caliph in the Battle of Oujda during which the Almohad Caliph was killed. In 1264 he managed to conquer Sijilmasa, therefore bringing Sijilmasa and Tlemcen, the two most important outlets for trans-Saharan trade under one authority. Sijilmasa remained under his control for 11 years. Before his death he instructed his son and heir Uthman to remain on the defensive with the Marinid kingdom, but to expand into Hafsid territory if possible.

14th century
For most of its history the kingdom was on the defensive, threatened by stronger states to the east and the west. The nomadic Arabs to the south also took advantage of the frequent periods of weakness to raid the centre and take control of pastures in the south.

The city of Tlemcen was several times attacked or besieged by the Marinids, and large parts of the kingdom were occupied by them for several decades in the fourteenth century.

The Marinid Abu Yaqub Yusuf an-Nasr besieged Tlemcen from 1299 to 1307. During the siege he built a new town, al-Mansura, diverting most of the trade to this town. The new city was fortified and had a mosque, baths and palaces. The siege was raised when Abu Yakub was murdered in his sleep by one of his eunuchs.

When the Marinids left in 1307, the Zayyanids promptly destroyed al-Mansura. The Zayyanid king Abu Zayyan I died in 1308 and was succeeded by Abu Hammu I (r. 1308–1318). Abu Hammu was later killed in a conspiracy instigated by his son and heir Abu Tashufin I (r. 1318–1337). The reigns of Abu Hammu I and Abu Tashufin I marked the second apogee of the Zayyanids, a period during which they consolidated their hegemony in the central Maghreb. Tlemcen recovered its trade and its population grew, reaching about 100,000 by around the 1330s. Abu Tashufin initiated hostilities against Ifriqiya while the Marinids were distracted by their internal struggles. He besieged Béjaïa and sent an army into Tunisia that defeated the Hafsid king Abu Yahya Abu Bakr II, who fled to Constantine while the Zayyanids occupied Tunis in 1325.

The Marinid sultan Abu al-Hasan (r. 1331–1348) cemented an alliance with Hafsids by marrying a Hafsid princess. Upon being attacked by the Zayyanids again, the Hafsids appealed to Abu al-Hasan for help, providing him with an excuse to invade his neighbour. The Marinid sultan initiated a siege of Tlemcen in 1335 and the city fell in 1337. Abu Tashufin died during the fighting. Abu al-Hasan received delegates from Egypt, Granada, Tunis and Mali congratulating him on his victory, by which he had gained complete control of the trans-Saharan trade. In 1346 the Hafsid Sultan, Abu Bakr, died and a dispute over the succession ensued. In 1347 Abu al-Hasan annexed Ifriqiya, briefly reuniting the Maghrib territories as they had been under the Almohads.

However, Abu al-Hasan went too far in attempting to impose more authority over the Arab tribes, who revolted and in April 1348 defeated his army near Kairouan. His son, Abu Inan Faris, who had been serving as governor of Tlemcen, returned to Fez and declared that he was sultan. Tlemcen and the central Maghreb revolted. The Zayyanid Abu Thabit I (1348-1352) was proclaimed king of Tlemcen. Abu al-Hasan had to return from Ifriqiya by sea. After failing to retake Tlemcen and being defeated by his son, Abu al-Hasan died in May 1351. In 1352 Abu Inan Faris recaptured Tlemcen. He also reconquered the central Maghreb. He took Béjaïa in 1353 and Tunis in 1357, becoming master of Ifriqiya. In 1358 he was forced to return to Fez due to Arab opposition, where he fell sick and was killed.

The Zayyanid king Abu Hammu Musa II (r. 1359–1389) next took the throne of Tlemcen. He pursued an expansionist policy, pushing towards Fez in the west and into the Chelif valley and Béjaïa in the east. He had a long reign punctuated by fighting against the Marinids or various rebel groups. The Marinids reoccupied Tlemcen in 1360 and in 1370. In both cases, the Marinids found they were unable to hold the region against local resistance. Abu Hammu attacked the Hafsids in Béjaïa again in 1366, but this resulted in Hafsid intervention in the kingdom's affairs. The Hafsid sultan released Abu Hammu's cousin, Abu Zayyan, and helped him in laying claim to the Zayyanid throne. This provoked an internecine war between the two Zayyanids until 1378, when Abu Hammu finally captured Abu Zayyan in Algiers.

The historian Ibn Khaldun lived in Tlemcen for a period during the generally prosperous reign of Abu Hammu Musa II, and helped him in negotiations with the nomadic Arabs. He said of this period, "Here [in Tlemcen] science and arts developed with success; here were born scholars and outstanding men, whose glory penetrated into other countries." Abu Hammu was deposed by his son, Abu Tashfin II (1389–94), and the state went into decline.

Decline (late 14th and 15th centuries)
In the late 14th century and the 15th century, the state was increasingly weak and became intermittently a vassal of Hafsid Ifriqiya, Marinid Morocco or the Crown of Aragon. In 1386 Abu Hammu moved his capital to Algiers, which he judged less vulnerable, but a year later his son, Abu Tashufin, overthrew him and took him prisoner. Abu Hammu was sent on a ship towards Alexandria but he escaped along the way when the ship stopped in Tunis. In 1388 he recaptured Tlemcen, forcing his son to flee. Abu Tashufin sought refuge in Fez and enlisted the aid of the Marinids, who sent an army to occupy Tlemcen and reinstall him on the throne. As a result, Abu Tashufin and his successors recognized the suzerainty of the Marinids and paid them an annual tribute.

During the reign of the Marinid sultan Abu Sa'id, the Zayyanids rebelled on several occasions and Abu Sa'id had to reassert his authority. After Abu Sa'id's death in 1420 the Marinids were plunged into political turmoil. The Zayyanid emir, Abu Malek, used this opportunity to throw off Marinid authority and captured Fez in 1423. Abu Malek installed Muhammad, a Marinid prince, as a Zayyanid vassal in Fez. The Wattasids, a family related to the Marinids, continued to govern from Salé, where they proclaimed Abd al-Haqq II, an infant, as the successor to the Marinid throne, with Abu Zakariyya al-Wattasi as regent. The Hafsid sultan, Abd al-Aziz II, reacted to Abu Malek's rising influence by sending military expeditions westward, installing his own Zayyanid client king (Abu Abdallah II) in Tlemcen and pursuing Abu Malek to Fez. Abu Malek's Marinid puppet, Muhammad, was deposed and the Wattasids returned with Abd al-Haqq II to Fez, acknowledging Hafsid suzerainty. The Zayyanids remained vassals of the Hafsids until the end of the 15th century, when the Spanish expansion along the coast weakened the rule of both dynasties.

By the end of the 15th century the Kingdom of Aragon had gained effective political control, intervening in the dynastic disputes of the amirs of Tlemcen, whose authority had shrunk to the town and its immediate neighbourship. When the Spanish took the city of Oran from the kingdom in 1509, continuous pressure from the Berbers prompted the Spanish to attempt a counterattack against the city of Tlemcen (1543), which was deemed by the Papacy to be a crusade. The Spanish under Martin of Angulo had also suffered a prior defeat in 1535 when they attempted to install a client ruler in Tlemcen. The Spanish failed to take the city in the first attack, but the strategic vulnerability of Tlemcen caused the kingdom's weight to shift toward the safer and more heavily fortified corsair base at Algiers.

Tlemcen was captured in 1551 by the Ottoman Empire under Hassan Pasha. The last Zayyanid sultan's son escaped to Oran, then a Spanish possession. He was baptized and lived a quiet life as Don Carlos at the court of Philip II of Spain.

Under the Ottoman Empire Tlemcen quickly lost its former importance, becoming a sleepy provincial town. The failure of the kingdom to become a powerful state can be explained by the lack of geographical or cultural unity, the constant internal disputes and the reliance on irregular Arab-Berber nomads for the military.

Christian conquest of Spain
The final triumph of the 700-year Christian conquest of Spain was marked by the fall of Granada in 1492. Christian Spain imposed its influence on the Maghrib coast by constructing fortified outposts and collecting tribute. But Spain never sought to extend its North African conquests much beyond a few modest enclaves. Privateering was an age-old practice in the Mediterranean, and North African rulers engaged in it increasingly in the late 16th and early 17th centuries because it was so lucrative. Until the 17th century the Barbary pirates used galleys, but a Dutch renegade of the name of Zymen Danseker taught them the advantage of using sailing ships.

Algeria became the privateering city-state par excellence, and two privateer brothers were instrumental in extending Ottoman influence in Algeria. At about the time Spain was establishing its presidios in the Maghrib, the Muslim privateer brothers Aruj and Khair ad Din—the latter known to Europeans as Barbarossa, or Red Beard—were operating successfully off Tunisia. In 1516 Aruj moved his base of operations to Algiers but was killed in 1518. Khair ad Din succeeded him as military commander of Algiers, and the Ottoman sultan gave him the title of beglerbey (provincial governor).

Spanish enclaves
The Spanish expansionist policy in North Africa began with the Catholic Monarchs and the regent Cisneros, once the Reconquista in the Iberian Peninsula was finished. That way, several towns and outposts in the Algerian coast were conquered and occupied: Mers El Kébir (1505), Oran (1509), Algiers (1510) and Bugia (1510). The Spanish conquest of Oran was won with much bloodshed: 4,000 Algerians were massacred, and up to 8,000 were taken prisoner. For about 200 years, Oran's inhabitants were virtually held captive in their fortress walls, ravaged by famine and plague; Spanish soldiers, too, were irregularly fed and paid.

The Spaniards left Algiers in 1529, Bujia in 1554, Mers El Kébir and Oran in 1708. The Spanish returned in 1732 when the armada of the Duke of Montemar was victorious in the Battle of Aïn-el-Turk and retook Oran and Mers El Kébir; the Spanish massacred many Muslim soldiers. In 1751, a Spanish adventurer, named John Gascon, obtained permission, and vessels and fireworks, to go against Algiers, and set fire, at night, to the Algerian fleet. The plan, however, miscarried. In 1775, Charles III of Spain sent a large force to attack Algiers, under the command of Alejandro O'Reilly (who had led Spanish forces in crushing French rebellion in Louisiana), resulting in a disastrous defeat. The Algerians suffered 5,000 casualties. The Spanish navy bombarded Algiers in 1784; over 20,000 cannonballs were fired, much of the city and its fortifications were destroyed and most of the Algerian fleet was sunk.

Oran and Mers El Kébir were held until 1792, when they were sold by the king Charles IV to the Bey of Algiers.

Regency of Algiers
The Regency of Algiers (دولة الجزائر) was a state in North Africa lasting from 1516 to 1830, until it was conquered by the French. Situated between the regency of Tunis in the east, the Sultanate of Morocco (from 1553) in the west and Tuat as well as the country south of In Salah in the south (and the Spanish and Portuguese possessions of North Africa), the Regency originally extended its borders from La Calle in the east to Trara in the west and from Algiers to Biskra, and afterwards spread to the present eastern and western borders of Algeria.

It had various degrees of autonomy throughout its existence, in some cases reaching complete independence, recognized even by the Ottoman sultan. The country was initially governed by governors appointed by the Ottoman sultan (1518–1659), rulers appointed by the Odjak of Algiers (1659–1710), and then Deys elected by the Divan of Algiers from (1710-1830).

Establishment
From 1496, the Spanish conquered numerous possessions on the North African coast: Melilla (1496), Mers El Kébir (1505), Oran (1509), Bougie (1510), Tripoli (1510), Algiers, Shershell, Dellys, and Tenes. The Spaniards later led unsuccessful expeditions to take Algiers in the Algiers expedition in 1516, 1519 and another failed expedition in 1541.

Around the same time, the Ottoman privateer brothers Oruç and Hayreddin—both known to Europeans as Barbarossa, or "Red Beard"—were operating successfully off Tunisia under the Hafsids. In 1516, Oruç moved his base of operations to Algiers. He asked for the protection of the Ottoman Empire in 1517, but was killed in 1518 during his invasion of the Zayyanid Kingdom of Tlemcen. Hayreddin succeeded him as military commander of Algiers.

In 1551 Hasan Pasha, the son of Hayreddin defeated the Spanish-Moroccan armies during a campaign to recapture Tlemcen, thus cementing Ottoman control in western and central Algeria.

After that, the conquest of Algeria sped up. In 1552 Salah Rais, with the help of some Kabyle kingdoms, conquered Touggourt, and established a foothold in the Sahara.

In the 1560s eastern Algeria was centralized, and the power struggle which had been present ever since the Emirate of Béjaïa collapsed came to an end.

During the 16th, 17th, and early 18th century, the Kabyle Kingdoms of Kuku and Ait Abbas managed to maintain their independence  repelling Ottoman attacks several times, notably in the First Battle of Kalaa of the Beni Abbes. This was mainly thanks to their ideal position deep inside the Kabylia Mountains and their great organisation, and the fact that unlike in the West and East where collapsing kingdoms such as Tlemcen or Béjaïa were present, Kabylia had two new and energetic emirates.

Base in the war against Spain
Hayreddin Barbarossa established the military basis of the regency. The Ottomans provided a supporting garrison of 2,000 Turkish troops with artillery. He left Hasan Agha in command as his deputy when he had to leave for Constantinople in 1533. The son of Barbarossa, Hasan Pashan was in 1544 when his father retired, the first governor of the Regency to be directly appointed by the Ottoman Empire. He took the title of beylerbey. Algiers became a base in the war against Spain, and also in the Ottoman conflicts with Morocco.

Beylerbeys continued to be nominated for unlimited tenures until 1587. After Spain had sent an embassy to Constantinople in 1578 to negotiate a truce, leading to a formal peace in August 1580, the Regency of Algiers was a formal Ottoman territory, rather than just a military base in the war against Spain. At this time, the Ottoman Empire set up a regular Ottoman administration in Algiers and its dependencies, headed by Pashas, with 3-year terms to help considate Ottoman power in the Maghreb.

Mediterranean privateers
Despite the end of formal hostilities with Spain in 1580, attacks on Christian and especially Catholic shipping, with slavery for the captured, became prevalent in Algiers and were actually the main industry and source of revenues of the Regency.

In the early 17th century, Algiers also became, along with other North African ports such as Tunis, one of the bases for Anglo-Turkish piracy. There were as many as 8,000 renegades in the city in 1634. (Renegades were former Christians, sometimes fleeing the law, who voluntarily moved to Muslim territory and converted to Islam.) Hayreddin Barbarossa is credited with tearing down the Peñón of Algiers and using the stone to build the inner harbor.

A contemporary letter states:

"'The infinity of goods, merchandise jewels and treasure taken by our English pirates daily from Christians and carried to Algire and Tunis to the great enriching of Mores and Turks and impoverishing of Christians'"

Privateers and slavery of Christians originating from Algiers were a major problem throughout the centuries, leading to regular punitive expeditions by European powers. Spain (1567, 1775, 1783), Denmark (1770), France (1661, 1665, 1682, 1683, 1688), England (1622, 1655, 1672), all led naval bombardments against Algiers. Abraham Duquesne fought the Barbary pirates in 1681 and bombarded Algiers between 1682 and 1683, to help Christian captives.

The Agha period
In 1659 the Janissaries of the Odjak of Algiers took over the country, and removed the local Pasha with the blessing of the Ottoman Sultan. From there on a system of dual leaders was in place. There was first and foremost the Agha, elected by the Odjak, and the Pasha appointed by the Ottoman Sublime Porte, whom was a major cause of unrest. Of course, this duality was not stable. All of the Aghas were assassinated, without an exception. Even the first Agha was killed after only 1 year of rule. Thanks to this the Pashas from Constantinople were able to increase the power, and reaffirm Turkish control over the region. In 1671, the Rais, the pirate captains, elected a new leader, Mohamed Trik. The Janissaries also supported him, and started calling him the Dey, which means Uncle in Turkish.

Early Dey period (1671-1710)
In the early Dey period the country worked similarly to before, with the Pasha still holding considerable powers, but instead of the Janissaries electing their own leaders freely, other factions such as the Taifa of Rais also wanted to elect the deys. Mohammed Trik, taking over during a time instability was faced with heavy issues. Not only were the Janissaries on a rampage, removing any leaders for even the smallest mistakes (even if those leaders were elected by them), but the native populace was also restless. The conflicts with European powers didn't help this either. In 1677, following an explosion in Algiers and several attempts at his life, Mohammed escaped to Tripoli leaving Algiers to Baba Hassan. Just 4 years into his rule he was already at war with one of the most powerful countries in Europe, the Kingdom of France. In 1682 France bombarded Algiers for the first time. The Bombardment was inconclusive, and the leader of the fleet Abraham Duquesne failed to secure the submission of Algiers. The next year, Algiers was bombarded again, this time liberating a few slaves. Before a peace treaty could be signed though, Baba Hassan was deposed and killed by a Rais called Mezzo Morto Hüseyin. Continuing the war against France he was defeated in a naval battle in 1685, near Cherchell, and at last a French Bombardment in 1688 brought an end to his reign, and the war. His successor, Hadj Chabane was elected by the Raïs. He defeated Morocco in the Battle of Moulouya and defeated Tunis as well. He went back to Algiers, but he was assassinated in 1695 by the Janissaries whom once again took over the country. From there on Algiers was in turmoil once again. Leaders were assassinated, despite not even ruling for a year, and the Pasha was still a cause of unrest. The only notable event during this time of unrest was the recapture of Oran and Mers-el-Kébir from the Spanish.

Coup of Baba Ali Chaouche, and independence
Baba Ali Chaouche, also written as Chaouch, took over the country, ending the rule of the Janissaries. The Pasha attempted to resist him, but instead he was sent home, and told to never come back, and if he did he will be executed. He also sent a letter to the Ottoman sultan declaring that Algiers will from then on act as an independent state, and will not be an Ottoman vassal, but an ally at best. The Sublime Porte, enraged, tried to send another Pasha to Algiers, whom was then sent back to Constantinople by the Algerians. This marked the de facto independence of Algiers from the Ottoman Empire.

Danish–Algerian War
In the mid-1700s Dano-Norwegian trade in the Mediterranean expanded. In order to protect the lucrative business against piracy, Denmark–Norway had secured a peace deal with the states of Barbary Coast. It involved paying an annual tribute to the individual rulers and additionally to the States.

In 1766, Algiers had a new ruler, dey Baba Mohammed ben-Osman. He demanded that the annual payment made by Denmark-Norway should be increased, and he should receive new gifts. Denmark–Norway refused the demands. Shortly after, Algerian pirates hijacked three Dano-Norwegian ships and allowed the crew to be sold as slaves.

They threatened to bombard the Algerian capital if the Algerians did not agree to a new peace deal on Danish terms. Algiers was not intimidated by the fleet, the fleet was of 2 frigates, 2 bomb galiot and 4 ship of the line.

Algerian-Sharifian War
In the west, the Algerian-Cherifian conflicts shaped the western border of Algeria.

There were numerous battles between the Regency of Algiers and the Sharifian Empires for example: the campaign of Tlemcen in 1551, the campaign of Tlemcen in 1557, the Battle of Moulouya and the Battle of Chelif. The independent Kabyle Kingdoms also had some involvement, the Kingdom of Beni Abbes participated in the campaign of Tlemcen in 1551 and the Kingdom of Kuku provided Zwawa troops for the capture of Fez in 1576 in which Abd al-Malik was installed as an Ottoman vassal ruler over the Saadi Dynasty. The Kingdom of Kuku also participated in the capture of Fez in 1554 in which Salih Rais defeated the Moroccan army and conquered Morocco up until Fez, adding these territories to the Ottoman crown and placing Ali Abu Hassun as the ruler and vassal to the Ottoman sultan. In 1792 the Regency of Algiers managed to take possession of the Moroccan Rif and Oujda, which they then abandoned in 1795 for unknown reasons.

Barbary Wars
During the early 19th century, Algiers again resorted to widespread piracy against shipping from Europe and the young United States of America, mainly due to internal fiscal difficulties, and the damage caused by the Napoleonic Wars. This in turn led to the First Barbary War and Second Barbary War, which culminated in August 1816 when Lord Exmouth executed a naval bombardment of Algiers, the biggest, and most successful one. The Barbary Wars resulted in a major victory for the American, British, and Dutch Navy.

1516-1567
In between 1516 and 1567, the rulers of the Regency were chosen by the Ottoman sultan. During the first few decades, Algiers was completely aligned with the Ottoman Empire, although it later gained a certain level of autonomy as it was the westernmost province of the Ottoman Empire, and administering it directly would have been problematic.

1567-1710
During this period a form of dual leadership was in place, with the Aghas sharing power and influence with a Pasha appointed by the Ottoman sultan from Constantinople. After 1567, the Deys became the main leaders of the country, although the Pashas still retained some power.

1710-1830
After a coup by Baba Ali Chaouch, the political situation of Algiers became complicated.

Relation with the Ottoman Empire
Some sources describe it as completely independent from the Ottomans, albeit the state was still nominally part of the Ottoman Empire.

Cur Abdy, dey of Algiers shouted at an Ottoman envoy for claiming that the Ottoman Padishah was the king of Algiers ("King of Algiers? King of Algiers? If he is the King of Algiers then who am I?").

Despite the Ottomans having no influence in Algiers, and the Algerians often ignoring orders from the Ottoman sultan, such as in 1784. In some cases Algiers also participated in the Ottoman Empire's wars, such as the Russo-Turkish War (1787–1792), albeit this was not common, and in 1798 for example Algiers sold wheat to the French Empire campaigning in Egypt against the Ottomans through two Jewish traders.

In some cases, Algiers was declared to be a country rebelling against the holy law of Islam by the Ottoman Caliph. This usually meant a declaration of war by the Ottomans against the Deylik of Algiers. This could happen due to many reasons. For example, under the rule of Haji Ali Dey, Algerian pirates regularly attacked Ottoman shipments, and Algiers waged war against the Beylik of Tunis, despite several protests by the Ottoman Porte, which resulted in a declaration of war.

It can be thus said that the relationship between the Ottoman Empire and Algiers mainly depended on what the Dey at the time wanted. While in some cases, if the relationship between the two was favorable, Algiers did participate in Ottoman wars, Algiers otherwise remained completely autonomous from the rest of the Empire similar to the other Barbary States.

19th century colonialism
North African boundaries have shifted during various stages of the conquests. The borders of modern Algeria were expanded by the French, whose colonization began in 1830 (French invasion began on July 5). To benefit French colonists (many of whom were not in fact of French origin but Italian, Maltese, and Spanish) and nearly the entirety of whom lived in urban areas, northern Algeria was eventually organized into overseas departments of France, with representatives in the French National Assembly. France controlled the entire country, but the traditional Muslim population in the rural areas remained separated from the modern economic infrastructure of the European community.

As a result of what the French considered an insult to the French consul in Algiers by the Day in 1827, France blockaded Algiers for three years. In 1830, France invaded and occupied the coastal areas of Algeria, citing a diplomatic incident as casus belli. Hussein Dey went into exile. French colonization then gradually penetrated southwards, and came to have a profound impact on the area and its populations. The European conquest, initially accepted in the Algiers region, was soon met by a rebellion, led by Abdel Kadir, which took roughly a decade for the French troops to put down. By 1848 nearly all of northern Algeria was under French control, and the new government of the French Second Republic declared the occupied lands an integral part of France. Three "civil territories"—Algiers, Oran, and Constantine—were organized as French départements (local administrative units) under a civilian government. During the "Pacification of Algeria", which lasted until 1903, the French perpetrated atrocities which included mass executions of civilians and prisoners and the use of concentration camps; many estimates indicates that the native Algerian population fell by one-third in the years between the French invasion and the end of fighting in the mid-1870s due to warfare, disease and starvation.

In addition to enduring the affront of being ruled by a foreign, non-Muslim power, many Algerians lost their lands to the new government or to colonists. Traditional leaders were eliminated, coopted, or made irrelevant, and the traditional educational system was largely dismantled; social structures were stressed to the breaking point. From 1856, native Muslims and Jews were viewed as French subjects not citizens.

However, in 1865, Napoleon III allowed them to apply for full French citizenship, a measure that few took, since it involved renouncing the right to be governed by sharia law in personal matters, and was considered a kind of apostasy; in 1870, the Crémieux Decree made French citizenship automatic for Jewish natives, a move which largely angered many Muslims, which resulted in the Jews being seen as the accomplices of the colonial power by anti-colonial Algerians. Nonetheless, this period saw progress in health, some infrastructures, and the overall expansion of the economy of Algeria, as well as the formation of new social classes, which, after exposure to ideas of equality and political liberty, would help propel the country to independence.

During the colonization France focused on eradicating the local culture by destroying hundreds years old palaces and important buildings. It is estimated that around half of Algiers, a city founded in the 10th century, was destroyed. Many segregatory laws were levied against the Algerians and their culture.

Rise of Algerian nationalism and French resistance
A new generation of Islamic leadership emerged in Algeria at the time of World War I and grew to maturity during the 1920s and 1930s. Various groups were formed in opposition to French rule, most notable the National Liberation Front (FLN) and the National Algerian Movement.

Colons (colonists), or, more popularly, pieds noirs (literally, black feet) dominated the government and controlled the bulk of Algeria's wealth. Throughout the colonial era, they continued to block or delay all attempts to implement even the most modest reforms. But from 1933 to 1936, mounting social, political, and economic crises in Algeria induced the indigenous population to engage in numerous acts of political protest. The government responded with more restrictive laws governing public order and security. Algerian Muslims rallied to the French side at the start of World War II as they had done in World War I. But the colons were generally sympathetic to the collaborationist Vichy regime established following France's defeat by Nazi Germany. After the fall of the Vichy regime in Algeria (November 11, 1942) as a result of Operation Torch, the Free French commander in chief in North Africa slowly rescinded repressive Vichy laws, despite opposition by colon extremists.

In March 1943, Muslim leader Ferhat Abbas presented the French administration with the Manifesto of the Algerian People, signed by 56 Algerian nationalist and international leaders. The manifesto demanded an Algerian constitution that would guarantee immediate and effective political participation and legal equality for Muslims. Instead, the French administration in 1944 instituted a reform package, based on the 1936 Viollette Plan, that granted full French citizenship only to certain categories of "meritorious" Algerian Muslims, who numbered about 60,000. In April 1945 the French had arrested the Algerian nationalist leader Messali Hadj. On May 1 the followers of his Parti du Peuple Algérien (PPA) participated in demonstrations which were violently put down by the police. Several Algerians were killed. The tensions between the Muslim and colon communities exploded on May 8, 1945, V-E Day, causing the Sétif and Guelma massacre. When a Muslim march was met with violence, marchers rampaged. The army and police responded by conducting a prolonged and systematic ratissage (literally, raking over) of suspected centers of dissidence. According to official French figures, 1,500 Muslims died as a result of these countermeasures. Other estimates vary from 6,000 to as high as 45,000 killed. Many nationalists drew the conclusion that independence could not be won by peaceful means, and so started organizing for violent rebellion.

In August 1947, the French National Assembly approved the government-proposed Organic Statute of Algeria. This law called for the creation of an Algerian Assembly with one house representing Europeans and "meritorious" Muslims and the other representing the remaining 8 million or more Muslims. Muslim and colon deputies alike abstained or voted against the statute but for diametrically opposed reasons: the Muslims because it fell short of their expectations and the colons because it went too far.

Algerian War of Independence (1954–1962)
The Algerian War of Independence (1954–1962), brutal and long, was the most recent major turning point in the country's history. Although often fratricidal, it ultimately united Algerians and seared the value of independence and the philosophy of anticolonialism into the national consciousness.

In the early morning hours of November 1, 1954, the National Liberation Front (Front de Libération Nationale—FLN) launched attacks throughout Algeria in the opening salvo of a war of independence. An important watershed in this war was the massacre of Pieds-Noirs civilians by the FLN near the town of Philippeville in August 1955. Which prompted Jacques Soustelle into calling for more repressive measures against the rebels. The French authorities claimed that 1,273 "guerrillas" died in what Soustelle admitted were "severe" reprisals. The FLN subsequently, giving names and addresses, claimed that 12,000 Muslims were killed. After Philippeville, all-out war began in Algeria. The FLN fought largely using guerrilla tactics whilst the French counter-insurgency tactics often included severe reprisals and repression.

Eventually, protracted negotiations led to a cease-fire signed by France and the FLN on March 18, 1962, at Evian, France. The Evian accords also provided for continuing economic, financial, technical, and cultural relations, along with interim administrative arrangements until a referendum on self-determination could be held. The Evian accords guaranteed the religious and property rights of French settlers, but the perception that they would not be respected led to the exodus of one million pieds-noirs and harkis.

Abusive tactics of the French Army remains a controversial subject in France to this day. Deliberate illegal methods were used, such as beatings, mutilations, hanging by the feet or hands, torture by electroshock, waterboarding, sleep deprivation and sexual assaults, among others. French war crimes against Algerian civilians were also committed, including indiscriminate shootings of civilians, bombings of villages suspected of helping the ALN, rape, disembowelment of pregnant women, imprisonment without food in small cells (some of which were small enough to impede lying down), throwing prisoners out of helicopters to their death or into the sea with concrete on their feet, and burying people alive.

The FLN also committed many atrocities, both against French pieds-noirs and against fellow Algerians whom they deemed as supporting the French. These crimes included killing unarmed men, women and children, rape and disembowelment or decapitation of women and murdering children by slitting their throats or banging their heads against walls.

Between 350,000 and 1 million Algerians are estimated to have died during the war, and more than 2 million, out of a total Muslim population of 9 or 10 million, were made into refugees or forcibly relocated into government-controlled camps. Much of the countryside and agriculture was devastated, along with the modern economy, which had been dominated by urban European settlers (the pied-noirs). French sources estimated that at least 70,000 Muslim civilians were killed or abducted and presumed killed, by the FLN during the Algerian War. Nearly one million people of mostly French, Spanish and Italian descent left the country at independence due to the privileges that they lost as settlers and their unwillingness to be on equal footing with indigenous Algerians along with them left most Algerians of Jewish descent and those Muslim Algerians who had supported a French Algeria (harkis). 30–150,000 pro-French Muslims were also killed in Algeria by FLN in post-war reprisals.

Ben Bella presidency (1962–65)
The Algerian independence referendum was held in French Algeria on 1 July 1962, passing with 99.72% of the vote. As a result, France declared Algeria independent on 3 July. On 8 September 1963, the first Algerian constitution was adopted by nationwide referendum under close supervision by the National Liberation Front (FLN). Later that month, Ahmed Ben Bella was formally elected the first president of Algeria for a five-year term after receiving support from the FLN and the military, led by Colonel Houari Boumédiène. However, the war for independence and its aftermath had severely disrupted Algeria's society and economy. In addition to the destruction of much of Algeria's infrastructure, an exodus of the upper-class French and European colons from Algeria deprived the country of most of its managers, civil servants, engineers, teachers, physicians, and skilled workers. The homeless and displaced numbered in the hundreds of thousands, many suffering from illness, and some 70 percent of the workforce was unemployed. The months immediately following independence witnessed the pell-mell rush of Algerians and government officials to claim the property and jobs left behind by the European colons. For example in the 1963 March Decrees, President Ben Bella declared all agricultural, industrial, and commercial properties previously owned and operated by Europeans vacant, thereby legalizing confiscation by the state.

The military played an important role in Ben Bella's administration. Since the president recognized the role that the military played in bringing him to power, he appointed senior military officers as ministers and other important positions within the new state, including naming Colonel Boumédiène as defence minister. These military officials played a core role into implementing the country's security and foreign policy.

Under the new constitution, Ben Bella's presidency combined the functions of chief of state and head of government with those of supreme commander of the armed forces. He formed his government without needing legislative approval and was responsible for the definition and direction of its policies. There was no effective institutional check on the president's powers. As a result, opposition leader Hocine Aït-Ahmed quit the National Assembly in 1963 to protest the increasingly dictatorial tendencies of the regime and formed a clandestine resistance movement, the Socialist Forces Front (Front des Forces Socialistes—FFS), dedicated to overthrowing the Ben Bella regime by force.

Late summer 1963 saw sporadic incidents attributed to the FFS, but more serious fighting broke out a year later, and the army moved quickly and in force to crush a rebellion. Minister of Defense Boumédiène had no qualms about sending the army to put down regional uprisings because he felt they posed a threat to the state. However, President Ben Bella attempted to co-opt allies from among these regional leaders in order to undermine the ability of military commanders to influence foreign and security policy. Tensions consequently built between Boumédiène and Ben Bella, and in 1965 the military removed Ben Bella in a coup d'état, replacing him with Boumédiène as head of state.

The 1965 coup and the Boumédienne military regime


On 19 June 1965, Houari Boumédiène deposed Ahmed Ben Bella in a military coup d'état that was both swift and bloodless. Ben Bella "disappeared", and would not be seen again until he was released from house arrest in 1980 by Boumédiène's successor, Colonel Chadli Bendjedid. Boumédiène immediately dissolved the National Assembly and suspended the 1963 constitution. Political power resided in the Nation Council of the Algerian Revolution (Conseil National de la Révolution Algérienne—CNRA), a predominantly military body intended to foster cooperation among various factions in the army and the party.

Houari Boumédiène's position as head of government and of state was initially insecure, partly because of his lack of a significant power base outside of the armed forces. He relied strongly on a network of former associates known as the Oujda group, named after Boumédiène's posting as National Liberation Army (Armée de Libération Nationale—ALN) leader in the Moroccan border town of Oujda during the war years, but he could not fully dominate his fractious regime. This situation may have accounted for his deference to collegial rule.

Over Boumédiène's 11-year reign as Chairman of the CNRA, the council introduced two formal mechanisms: the People's Municipal Assembly (Assemblée Populaires Communales) and the People's Provincial Assembly (Assemblée Populaires de Wilaya) for popular participation in politics. Under Boumédiène's rule, leftist and socialist concepts were merged with Islam.

Boumédiène also used Islam to opportunistically consolidate his power. On one hand, he made token concessions and cosmetic changes to the government to appear more Islamic, such as putting Islamist Ahmed Taleb Ibrahimi in charge of national education in 1965 and adopting policies criminalizing gambling, establishing Friday as the national holiday, and dropping plans to introduce birth control to paint an Islamic image of the new government. But on the other hand, Boumédiène's government also progressively repressed Islamic groups, such as by ordering the dissolution of Al Qiyam. Following attempted coups—most notably that of chief-of-staff Col. Tahar Zbiri in December 1967—and a failed assassination attempt on 25 April 1968, Boumédiène consolidated power and forced military and political factions to submit. He took a systematic, authoritarian approach to state building, arguing that Algeria needed stability and an economic base before building any political institutions.

Eleven years after Boumédiène took power, after much public debate, a long-promised new constitution was promulgated in November 1976. The constitution restored the National Assembly and gave it legislative, consent, and oversight functions. Boumédiène was later elected president with 95 percent of the cast votes.

Bendjedid rule (1978–92), the 1992 Coup d'État and the rise of the civil war
Boumédiène's death on 27 December 1978 set off a struggle within the FLN to choose a successor. A deadlock occurred between two candidates was broken when Colonel Chadli Bendjedid, a moderate who had collaborated with Boumédiène in deposing Ahmed Ben Bella, was sworn in on February 9, 1979. He was re-elected in 1984 and 1988. After the violent 1988 October Riots, a new constitution was adopted in 1989 that eradicated the Algerian one-party state by allowing the formation of political associations in addition to the FLN. It also removed the armed forces, which had run the government since the days of Boumédiène, from a role in the operation of the government.

Among the scores of parties that sprang up under the new constitution, the militant Islamic Salvation Front (Front Islamique du Salut—FIS) was the most successful, winning a majority of votes in the June 1990 municipal elections, as well as the first stage of the December national legislative elections.

The surprising first round of success for the fundamentalist FIS party in the December 1991 balloting caused the army to discuss options to intervene in the election. Officers feared that an Islamist government would interfere with their positions and core interests in economic, national security, and foreign policy, since the FIS has promised to make a fundamental re-haul of the social, political, and economic structure to achieve a radical Islamist agenda. Senior military figures, such as Defence Minister Khaled Nezzar, Chief of the General Staff Abdelmalek Guenaizia, and other leaders of the navy, Gendarmerie, and security services, all agreed that the FIS should be stopped from gaining power at the polling box. They also agreed that Bendjedid would need to be removed from office due to his determination to uphold the country's new constitution by continuing with the second round of ballots.

On 11 January 1992, Bendjedid announced his resignation on national television, saying it was necessary to "protect the unity of the people and the security of the country". Later that same day, the High Council of State (Haut Comité d'Etat—HCE), which was composed of five people (including Khaled Nezzar, Tedjini Haddam, Ali Kafi, Mohamed Boudiaf and Ali Haroun), was appointed to carry out the duties of the president.

The new government, led by Sid Ahmed Ghozali, banned all political activity at mosques and began stopping people from attending prayers at popular mosques. The FIS was legally dissolved by Interior Minister Larbi Belkheir on 9 February for attempting "insurrections against the state". A state of emergency was also declared and extraordinary powers, such as curtailing the right to associate, were granted to the regime.

Between January and March, a growing number of FIS militants were arrested by the military, including Abdelkader Hachani and his successors, Othman Aissani and Rabah Kebir. Following the announcement to dissolve the FIS and implement a state of emergency on 9 February, the Algerian security forces used their new emergency powers to conduct large scale arrests of FIS members and housed them in 5 "detention centers" in the Sahara. Between 5,000 (official number) and 30,000 (FIS number) people were detained.

This crackdown led to a fundamental Islamic insurgency, resulting in the continuous and brutal 10 year-long Algerian Civil War. During the civil war, the secular state apparatus nonetheless allowed elections featuring pro-government and moderate religious-based parties. The civil war lasted from 1991 to 2002.

Civil War and Bouteflika (1992–2019)
After Chadli Bendjedid resigned from the presidency in the military coup of 1992, a series of figureheads were selected by the military to assume the presidency, as officers were reluctant to assume public political power even though they had manifested control over the government. Additionally, the military's senior leaders felt a need to give a civilian face to the new political regime they had hastily constructed in the aftermath of Benjedid's ousting and the termination of elections, preferring a friendlier non-military face to front the regime.

The first such head of state was Mohamed Boudiaf, who was appointed president of the High Council of State (HCE) in February 1992 after a 27-year exile in Morocco. However, Boudiaf quickly came to odds with the military when attempts by Boudiaf to appoint his own staff or form a political party were viewed with suspicion by officers. Boudiaf also launched political initiatives, such as a rigorous anti-corruption campaign in April 1992 and the sacking of Khaled Nezzar from his post as Defence Minister, which were seen by the military as an attempt to remove their influence in the government. The former of these initiatives was especially hazardous to the many senior military officials who had benefited massively and illegally from the political system for years. In the end, Boudiaf was assassinated in June 1992 by one of his bodyguards with Islamist sympathies.

Ali Kafi briefly assumed the HCE presidency after Boudiaf's death, before Liamine Zéroual was appointed as a long-term replacement in 1994. However, Zéroual only remained in office for four years before he announced his retirement, as he quickly became embroiled in a clan warfare within the upper classes of the military and fell out with groups of the more senior generals. After this Abdelaziz Bouteflika, Boumédiène's foreign minister, succeeded as the president.

As the Algerian civil war wound to a close, presidential elections were held again in April 1999. Although seven candidates qualified for election, all but Abdelaziz Bouteflika, who had the support of the military as well as the National Liberation Front (FLN), withdrew on the eve of the election amid charges of electoral fraud and interference from the military. Bouteflika went on to win with 70 percent of the cast votes.

Despite the purportedly democratic elections, the civilian government immediately after the 1999 elections only acted as a sort of 'hijab' over the true government, mostly running day-to-day businesses, while the military still largely ran the country behind the scenes. For example, ministerial mandates to individuals were only granted with the military's approval, and different factions of the military invested in various political parties and the press, using them as pawns to gain influence.

However, the military's influence over politics decreased gradually, leaving Bouteflika with more authority on deciding policy. One reason for this was that the senior commanders who had dominated the political scene during the 1960s and 1970s started to retire. Bouteflika's former experience as Boumédiène's foreign minister earned him connections that rejuvenated Algeria's international reputation, which had been tarnished in the early 1990s due to the civil war. On the domestic front, Bouteflika's policy of "national reconciliation" to bring a close to civilian violence earned him a popular mandate that helped him to win further presidential terms in 2004, 2009 and 2014.

In 2010, journalists gathered to demonstrate for press freedom and against Bouteflika's self-appointed role as editor-in-chief of Algeria's state television station. In February 2011, the government rescinded the state of emergency that had been in place since 1992 but still banned all protest gatherings and demonstrations. However, in April 2011, over 2,000 protesters defied the official ban and took to the streets of Algiers, clashing with police forces. These protests can be seen as a part of the Arab Spring, with protesters noting that they were inspired by the recent Egyptian revolution, and that Algeria was a police state that was "corrupt to the bone".

In 2019, after 20 years in office, Bouteflika announced in February that he would seek a fifth term of office. This sparked widespread discontent around Algeria and protests in Algiers. Despite later attempts at saying he would resign after his term finished in late April, Bouteflika resigned on 2 April, after the chief of the army, Ahmed Gaid Salah, made a declaration that he was "unfit for office". Despite Gaid Salah being loyal to Bouteflika, many in the military identified with civilians, as nearly 70 percent of the army are civilian conscripts who are required to serve for 18 months. Also, since demonstrators demanded a change to the whole governmental system, many army officers aligned themselves with demonstrators in the hopes of surviving an anticipated revolution and retaining their positions.

After Bouteflika (2019-)
After the resignation of Abdelaziz Bouteflika on 9 April 2019, the President of the Council of the Nation Abdelkader Bensalah became acting president of Algeria.

Following the presidential election on 12 December 2019, Abdelmadjid Tebboune was elected president after taking 58% of the votes, beating the candidates from both main parties, the National Liberation Front and the Democratic National Rally.

On the eve of the first anniversary of the Hirak Movement, which led to the resignation of former president Bouteflika, President Abdelmadjid Tebboune announced in a statement to the Algerian national media that 22 February would be declared the Algerian "National Day of Fraternity and Cohesion between the People and Its Army for Democracy." In the same statement, Tebboune spoke in favor of the Hirak Movement, saying that "the blessed Hirak has preserved the country from a total collapse", and that he had "made a personal commitment to carry out all of the [movement's] demands." On 21 and 22 February 2020, masses of demonstrators (with turnout comparable to well-established Algerian holidays like the Algerian Day of Independence) gathered to honor the anniversary of the Hirak Movement and the newly established national day.

In an effort to contain the COVID-19 pandemic, Tebboune announced on 17 March 2020 that "marches and rallies, whatever their motives" would be prohibited. But after protesters and journalists were arrested for participating in such marches, Tebboune faced accusations of attempting to "silence Algerians." Notably, the government's actions were condemned by Amnesty International, which said in a statement that "when all eyes [...] are on the management of the COVID-19 pandemic, the Algerian authorities are devoting time to speeding up the prosecution and trial of activists, journalists, and supporters of the Hirak movement." The National Committee for the Liberation of Detainees (Comité national pour la libération des détenus—CNLD) estimated that around 70 prisoners of conscience were imprisoned by 2 July 2020 and that several of the imprisoned were arrested for Facebook posts.

On 28 December 2019, the then-recently inaugurated President Tebboune met with Ahmed Benbitour, the former Algerian Head of Government, with whom he discussed the "foundations of the new Republic." On 8 January 2020, Tebboune established a "commission of experts" composed of 17 members (a majority of which were professors of constitutional law) responsible for examining the previous constitution and making any necessary revisions. Led by Ahmed Laraba, the commission was required to submit its proposals to Tebboune directly within the following two months. In a letter to Laraba on the same day, Tebboune outlined seven axes around which the commission should focus its discussion. These areas of focus included strengthening citizens' rights, combating corruption, consolidating the balance of powers in the Algerian government, increasing the oversight powers of parliament, promoting the independence of the judiciary, furthering citizens' equality under the law, and constitutionalizing elections. Tebboune's letter also included a call for an "immutable and intangible" two-term limit to anyone serving as president — a major point of contention in the initial Hirak Movement protests, which were spurred by former president Abdelaziz Bouteflika's announcement to run for a fifth term.

The preliminary draft revision of the constitution was publicly published on 7 May 2020, but the Laraba Commission (as the "commission of experts" came to be known) was open to additional proposals from the public until 20 June. By 3 June, the commission had received an estimated 1,200 additional public proposals. After all revisions were considered by the Laraba Commission, the draft was introduced to the Cabinet of Algeria (Council of Ministers).

The revised constitution was adopted in the Council of Ministers on 6 September, in the People's National Assembly on 10 September, and in the Council of the Nation on 12 September. The constitutional changes were approved in the 1 November 2020 referendum, with 66.68% of voters participating in favour of the changes.

On 16 February 2021, mass protests and a wave of nationwide rallies and peaceful demonstrations against the government of Abdelmadjid Tebboune began. In May 2021, Algeria prohibited any protests that do not have prior approval by authorities.

Historiography and memory

 * Branche, Raphaëlle. "The martyr's torch: memory and power in Algeria." Journal of North African Studies 16.3 (2011): 431–443.
 * Cohen, William B. "Pied-Noir memory, history, and the Algerian War." in Europe's Invisible Migrants (2003): 129-145 online.
 * Hannoum, Abdelmajid. "The historiographic state: how Algeria once became French." History and Anthropology 19.2 (2008): 91-114. online
 * Hassett, Dónal. Mobilizing Memory: The Great War and the Language of Politics in Colonial Algeria, 1918-1939 (Oxford UP, 2019).
 * House, Jim. "Memory and the Creation of Solidarity during the Decolonization of Algeria." Yale French Studies 118/119 (2010): 15-38 online.
 * Johnson, Douglas. "Algeria: some problems of modern history." Journal of African history (1964): 221–242.
 * Lorcin, Patricia M.E., ed. Algeria and France, 1800-2000: identity, memory, nostalgia (Syracuse UP, 2006).
 * McDougall, James. History and the Culture of Nationalism in Algeria (Cambridge UP, 2006) excerpt.
 * Vince, Natalya. Our fighting sisters: Nation, memory and gender in Algeria, 1954–2012 (Manchester UP, 2072115).