M'Zab is a deep, narrow oasis valley located within the Sahara, consisting of five walled towns. The five towns, together known as the Pentapolis, were established in the 11th century by Mozabite Berbers.
The Mozabites were originally from a region historically known as the Maghreb. Their home town was Tahert. When a devastating fire destroyed their home in 909, the Mozabites left Tahert and settled in M'Zab valley. There, they built five fortified towns - each a miniature citadel, encircled by walls, and dominated by a mosque, whose minaret functioned as a watchtower.