The Berbers in present-day Algeria form in the second century the Kingdom of Numidia. Numidia becomes an ally of the Roman Empire in the war against Carthago. In 105 BC Numidia is conquered by the Roman Empire and it becomes in 46 part of the Roman province of Africa.

The area is conquered by the Vandals in the fifth century, followed by the East Roman Empire in the sixth century and the Caliphate in the seventh century. They name the region Maghreb. The Maghreb is ruled by succeeding Islamic dynasties and in 1147 it becomes part of the State of the Almohades. As a result of conflicts with Spain, the local population asks for support by the Ottoman Empire. This leads in 1519 to the incorporation into the Ottoman Empire as the province of Algeria, though de facto the Barbarian Pirates rule the area.

In 1830 Algeria is seized by France, followed by a formal annexation in 1840. Indigenous Algerians begin their revolt against French rule in 1954 to gain rights denied them under French rule. The revolution, launched by the Jabha al-Tahir a-Watani (National Liberation Front, FLN), is a guerrilla war in which both sides targeted civilians and otherwise use brutal tactics. In 1957 France secedes the southern parts from Algeria and establishes the separate territory of Sahara. Negotiations lead to a cease-fire signed by France and the FLN in 1962 and as a result of that over one million French citizens living in Algeria at the time leave the country.

Algeria unites with Sahara and becomes independent in 1962, initially as the Algerian State, later that year renamed People's Democratic Republic of Algeria. Algeria becomes a one-party state, lead by the FLN of Ahmed Ben Bella, who becomes president in 1963. After a coup in 1965 Houari Boumedienne becomes president until his death in 1978, when he is succeeded by Benjedid Chadli.

In 1989 Algeria moves from a one-party state into a multi-party democracy. New elections are announced for 1991. When a victory of the fundamentalist Front Islamicque du Salut (Islamic Salvation Front, FIS) seems to be imminent, the second round of these elections are cancelled and Algeria becomes a military dictatorship with initially Mohamed Boudiaf and after his assassination Liameine Zéroual as president. During his rule the Armed Islamic Group (GIA) launches terrorist campaigns against government figures and institutions to protest the banning of the islamist parties. Government officials estimate that more than 100,000 Algerians die during this period.

Algeria becomes a presidential-parliamentary democracy in 1996, with relative free elections, though often boycotted by opposition parties. After the elections of 1997 the Rassemblement National Démocratique (National Democratic Rally, RND) of Zéroual becomes the largest party. This party forms a coalition with the Harakat Moudjtamaa as-Silm (Movement of Society for Peace, MSP) and the FLN. The presidential elections of 1999 are won by Abdelaziz Bouteflika of the FLN, following a campaign in which seven candidates qualify for election. On the eve of the election, all candidates except Abdelaziz Bouteflika pull out amid charges of widespread electoral fraud. President Bouteflika's agenda focuses initially on restoring security and stability to the country. This policy is approved in a nationwide referendum in 2000. The security situation in Algeria improves. However, terrorism has not been totally eliminated, and terrorist incidents still occur, particularly in remote or isolated areas of the country. In 2001 the Amazigh language of the Berber minority is recognized as a national language. Bouteflika is re-elected in 2004 as a candidate of the RND and the MSP.