# History of Somalia

Somalia (Somali: Somaliya; aṣ-Ṣūmāl), officially the Federal Republic of Somalia (Somali: Jamhuuriyadda Federaalka Soomaaliya, Jumhūriyyat aṣ-Ṣūmāl al-Fideraaliya) and formerly known as the Somali Democratic Republic, is a country located in the Horn of Africa.
In antiquity, the region now known as Somalia was referred to as the second "Barbaria" by the Greeks and Romans; similarly, Arab sources, including the geographer al Idrisi, identified it as al-Barbara. The country was an important centre for commerce with the rest of the ancient world, and according to most scholars, it was the seat of ancient Land of Punt that thrived during bronze age. During the classic era until the Middle Ages, several powerful Somali states and port towns dominated the regional trade, including the Sultanate of Mogadishu and the Ajuran Sultanate, both centered around the port town of Mogadishu. Additionally, the port towns of Barawe and Merca played significant roles in this commercial network which were part of the Azania city states during classic era. Preceding these medieval states were ancient civilisations such as the legendary Macrobian Kingdom, noted by Herodotus for its wealth and wisdom, and the Barbario civilisation, an early pre-Islamic civilisation that helped lay the foundations for the region's prosperous trade routes.
In the late 19th century, through a succession of treaties with these kingdoms, the Italian colonial empire gained control of parts of the coast, and established the colony of Italian Somaliland. In southern parts of Somalia, the Italians fought a decades-long war, dubbed the Banadir Resistance, with the Somalis around the port town of Merca. Italy acquired full control of the northeastern, central and southern parts of the territory after successfully waging a Campaign of the Sultanates against the ruling Majeerteen Sultanate and the Sultanate of Hobyo. This occupation lasted until 1941 when it was replaced by a British military administration.
In 1950, the Trust Territory of Somaliland under Italian administration was established as a United Nations Trusteeship, with a promise of independence after 10 years. British Somaliland, nominally independent as the State of Somaliland (now Somaliland) for four days, merged as planned with the trust territory in 1960. Together, they formed the independent Somali Republic under a civilian government, the Somali National Assembly, headed by Haji Bashir Ismail Yusuf. The administration lasted until 1969, when the Supreme Revolutionary Council led by Mohamed Siad Barre, seized power in a bloodless coup and renamed the country the Somali Democratic Republic. In 1991, the Somali Civil War divided the entire country. Despite the establishment of the Interim, Transitional, and Federal governments, Somalia remains divided with Somaliland gaining de facto independence.

## Prehistory

Somalia has been inhabited since at least the Paleolithic, when the Doian and Hargeisan cultures flourished. The oldest evidence of burial customs in the Horn of Africa comes from cemeteries in Somalia dating back to the 4th millennium BC. The stone implements from the Jalelo site in the north (about halfway between Berbera and Hargeisa) were also characterized in 1909 as important artefacts demonstrating the archaeological universality during the Paleolithic between the East and the West.
According to an autosomal DNA research in 2014 on ancient and modern populations, the Afroasiatic languages likely spread across Africa and the Near East by an ancestral population(s) carrying a newly identified "non-African" (Western Eurasian) genetic component, which the researchers dub the "Ethio-Somali" component. This genetic component is most closely related to the "Maghrebi" component and is believed to have diverged from other "non-African" (Western Eurasian) ancestries at least 23,000 years ago. The "Ethio-Somali" genetic component is prevalent among modern Afroasiatic-speaking populations, and found at its highest levels among Cushitic peoples in the Horn of Africa. On this basis, the researchers suggest that the original Ethio-Somali carrying population(s) probably arrived in the pre-agricultural period (12–23 ka) from the Near East, having crossed over into northeast Africa via the Sinai Peninsula and then split into two, with one branch continuing west across North Africa and the other heading south into the Horn of Africa. A similar view has already been proposed earlier, suggesting that the ancestors of Afroasiatic speakers could have been a population originating in the Near East that migrated to Northeast Africa during the Late Palaeolithic with a subset later moving back to the Near East. According to Anthropologists, the ancestors of the Somali people arrived in the region during the ensuing Neolithic period.
The Laas Geel cave complex on the outskirts of Hargeisa in northwestern Somalia has rock art which dates back around 5,000 years and has depicting both wild animals and decorated cows. Other cave paintings are found in the northern Dhambalin region, which feature one of the earliest known depictions of a hunter on horseback. The rock art is in the distinctive Ethiopian-Arabian style, dated to 1000 to 3000 BCE. Additionally, between the towns of Las Khorey and El Ayo in northern Somalia lies Karinhegane, the site of numerous cave paintings of real and mythical animals. Each painting has an inscription below it, which collectively have been estimated to be around 2,500 years old.

## Ancient

Ancient Somalia domesticated the camel somewhere between the third millennium and second millennium BCE from where it spread to Ancient Egypt and North Africa.

### Land of Punt

Ancient pyramidical structures, mausoleums, ruined cities and stone walls found in Somalia (such as the Wargaade Wall) are evidence of an old sophisticated civilization that once thrived in the Somali peninsula. The findings of archaeological excavations and research in Somalia show that this civilization enjoyed a lucrative trading relationship with Ancient Egypt and Mycenaean Greece since the second millennium BCE. This supports the hypothesis of Somalia and/or the adjacent Horn territories corresponding with the ancient Land of Punt. The Puntites traded myrrh, spices, gold, ebony, short-horned cattle, ivory and frankincense with the Ancient Egyptians, Phoenicians, Babylonians, Indians, Chinese and Romans through their commercial ports. An Ancient Egyptian expedition sent to Punt by the 18th dynasty Queen Hatshepsut is recorded on the temple reliefs at Deir el-Bahari, during the reign of the Puntite King Parahu and Queen Ati. According to Christiane Noblecourt, these expeditions were further facilitated by the existence of a common language between Egypt and Punt. Traces of these ties also survive in Somali folklore. One recorded myth describes the origin of the Egyptian Pharaohs as follows:
“There were once two brothers: one tall and strong, the other short and thin; they lived in the Peninsula. One day the little one, very jealous of his brother, went north and settled in Egypt. And since he had an inferiority complex, he built great pyramids and sculpted huge statues.”
One of the main scholarly work on Punt, written from a native Somali standpoint, was by Somali historian Muxamed Ibraahim Muxamed, who wrote the work: Taariikhda Soomaaliya: dalkii filka weynaa ee punt.

### Somali City States

Ancient urban centers and trade networks in Somalia have long attracted scholarly attention. Archaeological surveys in northern Somalia have identified over seventy ruined towns, including four urban centers that date to around 2,000 years ago: Salweyn (Mundus), Daamo (Cape of Spices), and two settlements in Xaafun (Opone). Archaeological research indicates a culture of literacy in these city-states, as hundreds of ancient inscriptions have been uncovered, including as-yet-undeciphered indigenous scripts.
Little is known about the dynasties that ruled these city-states. One local tradition recounts a King of Barbary who had two daughters, “Hoobaal” and “Heelley,” stating that the king’s love for them was so great that it compelled future generations of Somali composers and poets to introduce their names at the beginning or end of their works. Additionally, some depictions of rulers from these city-states, dating to roughly 2,000 years ago, have been identified, potentially offering visual evidence of their reigns.
In the classical period, the Somali city-states of Mosylon, Opone, Malao, Sarapion, Mundus, Essina and Tabae in Somalia developed a lucrative trade network connecting with merchants from Phoenicia, Ptolemic Egypt, Greece, Parthian Persia, Sheba, Nabataea and the Roman Empire. They used the ancient Somali maritime vessel known as the beden to transport their cargo. By around 300 BC, certain historical records identify Somali sailors as among the most active in the Indian Ocean, surpassing Arab mariners in maritime trade.
After the Roman conquest of the Nabataean Empire and the Roman naval presence at Aden to curb pillaging, Somali and Gulf Arab merchants by agreement barred Indian ships from trading in the free port cities of the Arabian Peninsula to protect the interests of Somali and Arab merchants in the extremely lucrative ancient Red Sea–Mediterranean Sea commerce. However, Indian merchants continued to trade in the port cities of the Somali Peninsula, which was free from Roman interference.
For centuries, the Indian merchants brought large quantities of cinnamon from Sri Lanka and Indonesia to Somalia and Arabia. This is said to have been the best kept secret of the Somali and Gulf Arab merchants in their trade with the Roman and Greek world. The Romans and Greeks believed the source of cinnamon to have been the Somali peninsula, but in reality, the highly valued product was brought to Somalia by way of Indian ships. Through collusive agreement by Somali and Gulf Arab traders, Indian/Chinese cinnamon was also exported for far higher prices to North Africa, the Near East and Europe, which made the cinnamon trade a very profitable revenue generator, especially for the Somali merchants through whose hands large quantities were shipped across ancient sea and land routes.

## Medieval

Islam was introduced to the northern Somali coast early on from the Arabian peninsula, shortly after the hijra (aka migration to Abyssinia). Zeila's two-mihrab Masjid al-Qiblatayn dates to the 7th century, and is the oldest mosque in Africa. In the late 9th century, Al-Yaqubi wrote that Muslims were living along the northern Somali seaboard. He also mentioned that the Adal kingdom had its capital in the city, suggesting that Adal with Zeila as its headquarters dates back to at least the 9th or 10th century. Adal's history from this founding period forth would, as a vassal of the Sultanate of Ifat, be characterized by a succession of battles with neighbouring Abyssinia. According to Ibn al Mujawir, by 1228–9 AD emerging polities in northern Somalia had grown powerful enough to capture the Yemeni port of Aden from the 'Al Qumr' and construct its waterworks.
Throughout the Middle Ages, Arab immigrants arrived in Somalia, a historical experience which would later lead to the legendary stories about Muslim sheikhs such as Daarood and Ishaaq bin Ahmed (the purported ancestors of the Darod and Isaaq clans, respectively) travelling from Arabia to Somalia and marrying into the local Dir clan.
The Sultanate of Mogadishu's first dynasty was established by Abubakr bin Fakhr ad-Din. This ruling house was succeeded by different dynasties like the Qahtani, Hilwaani and eventually the Muzaffar dynasty and remained a powerful regional trading city-state, being the first to make use of the gold mines in Sofala. Eventually at the end of the 16th century the Muzaffarid dynasty allied themselves to the Somali Ajuran Empire For many years, Mogadishu stood as the pre-eminent city in the بلاد البربر, Bilad-al-Barbar ("Land of the Berbers"), which was the medieval Arab term for the Somali coast. Following his visit to the city, the 12th century Syrian historian Yaqut al-Hamawi wrote that it was inhabited by "Berbers", the ancestors of the modern Somalis.
The conquest of Shoa ignited a rivalry for supremacy between the Christian Solomonids and the Muslim Ifatites, which resulted in several devastating wars and ultimately ended in a Solomonic victory over the Sultanate of Ifat. Parts of northwestern Somalia came under the rule of the Solomonids in medieval times, especially during the reign of Amda Seyon I (r. 1314–1344). In 1403 or 1415 (under Emperor Dawit I or Emperor Yeshaq I, respectively), measures were taken against the Muslim Sultanate of Adal. The Emperor eventually captured King Sa'ad ad-Din II of the Walashma dynasty in Zeila and had him executed. The Walashma Chronicle, however, records the date as 1415, which would make the Ethiopian victor Emperor Yeshaq I. After the war, the reigning king had his minstrels compose a song praising his victory, which contains the first written record of the word "Somali". Sa'ad ad-Din II's family was subsequently given safe haven at the court of the King of Yemen, where his sons regrouped and planned their revenge on the Solomonids.
The oldest son Sabr ad-Din II built a new capital eastwards of Zeila known as Dakkar and began referring to himself as the King of Adal. He continued the war against the Solomonic Empire. Despite his army's smaller size, he was able to defeat the Solomonids at the battles of Serjan and Zikr Amhara and consequently pillaged the surrounding areas. Many similar battles were fought between the Adalites and the Solomonids with both sides achieving victory and suffering defeat but ultimately Sultan Sabr ad-Din II successfully managed to drive the Solomonic army out of Adal territory. He died a natural death and was succeeded by his brother Mansur ad-Din who invaded the capital and royal seat of the Solomonic Empire and drove Emperor Dawit II to Yedaya where according to al-Maqrizi, Sultan Mansur destroyed a Solomonic army and killed the Emperor. He then advanced to the mountains of Mokha, where he encountered a 30,000 strong Solomonic army. The Adalite soldiers surrounded their enemies and for two months besieged the trapped Solomonic soldiers until a truce was declared in Mansur's favour.
Later on in the campaign, the Adalites were struck by a catastrophe when Sultan Mansur and his brother Muhammad were captured in battle by the Solomonids. Mansur was immediately succeeded by the youngest brother of the family Jamal ad-Din II. Sultan Jamal reorganized the army into a formidable force and defeated the Solomonic armies at Bale, Yedeya and Jazja. Emperor Yeshaq I responded by gathering a large army and invaded the cities of Yedeya and Jazja but was repulsed by the soldiers of Jamal. Following this success, Jamal organized another successful attack against the Solomonic forces and inflicted heavy casualties in what was reportedly the largest Adalite army ever fielded. As a result, Yeshaq was forced to withdraw towards the Blue Nile over the next five months, while Jamal ad Din's forces pursued them and looted much gold on the way, although no engagement ensued.
After returning home, Jamal sent his brother Ahmad with the Christian battle-expert Harb Jaush to successfully attack the province of Dawaro. Despite his losses, Emperor Yeshaq was still able to continue field armies against Jamal. Sultan Jamal continued to advance further into the Abyssinian heartland. However, Jamal on hearing of Yeshaq's plan to send several large armies to attack three different areas of Adal (including the capital), returned to Adal, where he fought the Solomonic forces at Harjai and, according to al-Maqrizi, this is where the Emperor Yeshaq died in battle. The young Sultan Jamal ad-Din II at the end of his reign had outperformed his brothers and forefathers in the war arena and became the most successful ruler of Adal to date. Within a few years, however, Jamal was assassinated by either disloyal friends or cousins around 1432 or 1433, and was succeeded by his brother Badlay ibn Sa'ad ad-Din. Sultan Badlay continued the campaigns of his younger brother and began several successful expeditions against the Christian empire. He recovered the Kingdom of Bali and began preparations of a major Adalite offensive into the Ethiopian Highlands. He successfully collected funding from surrounding Muslim kingdoms as far away as the Kingdom of Mogadishu. However, these ambitious plans were thrown out the war chamber when King Badlay died during the invasion of Dawaro. He was succeeded by his son Muhammad ibn Badlay, who sent envoys to the Sultan of Mamluk Egypt to gather support and arms in the continuing war against the Christian empire. The Adalite ruler Muhammad and the Solomonic ruler Baeda Maryam agreed to a truce and both states in the following decades saw an unprecedented period of peace and stability.

## Early modern

Sultan Muhammad was succeeded by his son Shams ad Din, while Emperor Baeda Maryam was succeeded by his son Eskender. During this time, period warfare broke out again between the two states and Emperor Eskender invaded Dakkar, where he was stopped by a large Adalite army, which destroyed the Solomonic army to such an extent that no further expeditions were carried out for the remainder of Eskender's reign. Adal, however, continued to raid the Christian empire unabated under the leadership of General Mahfuz, the leader of the Adalite war machine, who annually invaded the Christian territories. Eskender was succeeded by Emperor Na'od, who tried to defend the Christians from General Mahfuz but he too was also killed in battle by the Adalite army in Ifat.
At the turn of the 16th century, Adal regrouped and, around 1527, under the charismatic leadership of Imam Ahmad ibn Ibrahim al-Ghazi (Gurey in Somali meaning "left-handed"), invaded Abyssinia. Adalite armies marched into Ethiopia and caused considerable damage on the highland state. Many historic churches, manuscripts and settlements were looted and burned during the campaigns. Ahmad’s remarkable martial skill allowed the conquest of the entirety of Ethiopia, reaching as far north as Tigray. The Ethiopian Emperor was forced to live as a naked outlaw hounded by the victorious Imam’s armies. The complete destruction of the Solomonic Dynasty was averted by the timely arrival of a Portuguese expedition led by Cristóvão da Gama, son of the famed navigator Vasco da Gama. The Portuguese had been in the area earlier – in the early 16th century, in search of the legendary priest-king Prester John – and, although a diplomatic mission from Portugal, led by Rodrigo de Lima, had failed to improve relations between the countries, they responded to the Ethiopian pleas for help and sent a military expedition to their fellow Christians. A Portuguese fleet under the command of Estêvão da Gama was sent from Portuguese India and arrived at Massawa in February 1541. Here, he received an ambassador from the Emperor beseeching him to send help against the Muslims. In July, a force of 400 musketeers, under the command of Cristóvão da Gama, younger brother of Estêvão, marched into the interior. Joined by Ethiopian troops, they were at first successful against the Muslims; but, they were subsequently defeated at the Battle of Wofla (28 August 1542), and their commander captured and executed. On 21 February 1543, however, a joint Portuguese-Ethiopian force defeated the Muslim army at the Battle of Wayna Daga, in which Ahmed Gurey was killed and the war won. Ahmed Gurey's widow married his nephew Nur ibn Mujahid, in return for his promise to avenge Ahmed's death, who succeeded Ahmed Gurey, and continued hostilities against his northern adversaries until he killed the Ethiopian Emperor in his second invasion of Ethiopia.
The Sultanate of Adal would later be succeeded by the Imamate of Awsame established by Imam Muhammad Gasa after he was elected due to his illustrious lineage being related to the Imam. He would switch the capital of the Sultanate to Awsa after the Oromo hordes had camped outside of the city of Harar doing numerous raids on the city's inhabitants. The Imam would successfully defeat them from the city of Zeila to the outskirts of the Imamate, and his dynasty would rule for the next 157 years until it would be over thrown by the Mudaito Afar dynasty, who would kick out the Marehan immigrants from Harar formulating a poem about their expansion. A huge contingent of Somalis remained in their regions and were absorbed by the Afar such as the Marehan, Karanle and Facaaye.
During the age of the Ajurans, the sultanates and republics of Merca, Mogadishu, Barawa, Hobyo and their respective ports flourished and had a lucrative foreign commerce with ships sailing to and coming from Arabia, India, Venetia, Persia, Egypt, Portugal and as far away as China. Vasco da Gama, who passed by Mogadishu in the 15th century, noted that it was a large city with houses of four or five storeys and big palaces in its centre and many mosques with cylindrical minarets. In the 16th century, Duarte Barbosa noted that many ships from the Kingdom of Cambaya in India sailed to Mogadishu with cloths and spices, for which they in return received gold, wax and ivory. Barbosa also highlighted the abundance of meat, wheat, barley, horses, and fruit on the coastal markets, which generated enormous wealth for the merchants.
Mogadishu, the center of a thriving weaving industry known as toob benadir (specialized for the markets in Egypt and Syria), together with Merca and Barawa also served as transit stops for Swahili merchants from Mombasa and Malindi and for the gold trade from Kilwa. Jewish merchants from the Hormuz brought their Indian textile and fruit to the Somali coast in exchange for grain and wood. Trading relations were established with Malacca in the 15th century with cloth, ambergris and porcelain being the main commodities of the trade. Giraffes, zebras and incense were exported to the Ming dynasty of China, which established Somali merchants as leaders in the commerce between the Asia and Africa. Hindu merchants from Surat and Southeast African merchants from Pate, seeking to bypass both the Portuguese blockade and Omani meddling, used the Somali ports of Merca and Barawa (which were out of the two powers' jurisdiction) to conduct their trade in safety and without interference.
The 16th century Somali-Portuguese wars in East Africa meant that geopolitical tensions would remain high. The increased contact between Somali sailors and Ottoman corsairs worried the Portuguese, who sent multiple punitive expeditions against the Ajuran Empire in order to pacify the Somali port cities. For example, the city of Barawa was sacked by a Portuguese fleet led by Tristão da Cunha in the Battle of Barawa (1507). In 1542, the Portuguese commander João de Sepúvelda led a small fleet on an expedition to the Somali coast. During this expedition he briefly attacked Mogadishu, capturing an Ottoman ship and firing upon the city, which compelled the sultan of Mogadishu to sign a peace treaty with the Portuguese. Sailing on to Barawa, João de Sepúvelda again sacked that city and secured a new peace from it. Ottoman-Somali cooperation against the Portuguese in the Indian Ocean reached a high point in the 1580s when Ajuran clients of the Somali coastal cities began to sympathize with the Arabs and Swahilis under Portuguese rule and sent an envoy to the Turkish corsair Mir Ali Bey for a joint expedition against the Portuguese. He agreed and was joined by a Somali fleet, which began attacking Portuguese colonies in Southeast Africa. The Somali-Ottoman offensive managed to drive out the Portuguese from several important cities such as Pate, Mombasa and Kilwa. However, the Portuguese governor sent envoys to India requesting a large Portuguese fleet. This request was answered and it reversed the previous offensive of the Muslims into one of defense. The Portuguese armada managed to re-take most of the lost cities and began punishing their leaders, but they refrained from attacking Mogadishu.
Berbera, the main port of the Isaaq Sultanate, was the most important port in the Horn of Africa between the 18th–19th centuries. For centuries, Berbera had extensive trade relations with several historic ports in the Arabian Peninsula. Additionally, the Somali and Ethiopian interiors were very dependent on Berbera for trade, where most of the goods for export arrived from. During the 1833 trading season, the port town swelled to over 70,000 people, and upwards of 6,000 camels laden with goods arrived from the interior within a single day. Berbera was the main marketplace in the entire Somali seaboard for various goods procured from the interior, such as livestock, coffee, frankincense, myrrh, acacia gum, saffron, feathers, ghee, hide (skin), gold and ivory.
According to a trade journal published in 1856, Berbera was described as "the freest port in the world, and the most important trading place on the whole Arabian Gulf".:
   "The only seaports of importance on this coast are Feyla [Zeila] and Berbera; the former is an Arabian colony, dependent of Mocha, but Berbera is independent of any foreign power. It is, without having the name, the freest port in the world, and the most important trading place on the whole Arabian Gulf. From the beginning of November to the end of April, a large fair assembles in Berbera, and caravans of 6,000 camels at a time come from the interior loaded with coffee, (considered superior to Mocha in Bombay), gum, ivory, hides, skins, grain, cattle, and sour milk, the substitute of fermented drinks in these regions; also much cattle is brought there for the Aden market."
Historically, the port of Berbera was controlled indigenously between the mercantile Reer Ahmed Nuh and Reer Yunis Nuh sub-clans of the Habar Awal.
In Somaliland, the Isaaq Sultanate was established in 1750. The Isaaq Sultanate was a Somali kingdom that ruled parts of the Horn of Africa during the 18th and 19th centuries. It spanned the territories of the Isaaq clan, descendants of the Banu Hashim clan, in modern-day Somaliland and Ethiopia. The sultanate was governed by the Rer Guled branch established by the first sultan, Sultan Guled Abdi, of the Eidagale clan. According to oral tradition, prior to the Guled dynasty the Isaaq clan-family were ruled by a dynasty of the Tolje'lo branch starting from, descendants of Ahmed nicknamed Tol Je'lo, the eldest son of Sheikh Ishaaq's Harari wife. There were eight Tolje'lo rulers in total who ruled for centuries starting from the 13th century. The last Tolje'lo ruler Boqor Harun (Somali: Boqor Haaruun), nicknamed Dhuh Barar (Somali: Dhuux Baraar) was overthrown by a coalition of Isaaq clans. The once strong Tolje'lo clan were scattered and took refuge amongst the Habr Awal with whom they still mostly live.

## 19th century

In 1841, Haji Sharmarke Ali Saleh, a successful and ambitious Somali merchant, successfully invaded Zeila utilizing canons and Somali Musketeers. He deposed and imprisoned the port town's Arab ruler and succeeded him as the undisputed ruler of Zeila and its dependencies. Sharmarke's governorship had an instant effect on the city, as he maneuvered to monopolize as much of the regional trade as possible, with his sights set as far as Harar and the Ogaden. In 1845, Sharmarke deployed a few matchlock men to wrest control of neighboring Berbera from that town's then-feuding Somali authorities.
Sharmarke's influence was not limited to the coast as he had many allies in the interior of the Somali country and even further in Abyssinia. Among his allies were the Sultans of Shewa. After the Amir of Harar Abu Bakr II ibn ʽAbd al-Munan arrested one of Sharmarke's agents in Harar, there was tension between the two rulers. Sharmarke persuaded the son of Sahle Selassie, ruler of Shewa, to imprison on his behalf about 300 citizens of Harar then resident in Shewa, for a length of two years.
Sultan Yusuf Mahamud Ibrahim, the third Sultan of the House of Gobroon, began the Golden age of the Gobroon dynasty. In 1843, his army came out victorious during the Bardheere jihad, which restored stability in the region and revitalized the East African ivory trade. He also received presents and had cordial relations with the leaders of neighbouring and distant kingdoms such as the Omani, Wituland and Yemeni sultans.
Sultan Ibrahim's son Ahmed Yusuf succeeded him and was one of the most important figures in 19th-century East Africa. He managed to gather 20 thousand Somali troops, invaded and captured the island of Zanzibar, defeating the enemy troops and freeing the Bantu slaves. Through his military dominance, Sultan Yusuf managed to exact tribute from the Omani king in the coastal town of Lamu.
In northern and southern Somalia, the Gerad Dynasty conducted trade with Yemen and Persia and competed with the merchants of the Bari Dynasty. The Gerads and the Bari Sultans built impressive palaces, castles and fortresses and had close relations with many different empires in the Near East.
In the late 19th century, after the Berlin Conference, European powers began the Scramble for Africa, which inspired the Dervish leaders in the north like Mohammed Abdullah Hassan and Sultan Nur Ahmed Aman to rally support from across the Horn of Africa, but also Sheikh Abikar Gafle to start a resistance around Merca called the Banadir Resistance. Both the Banadir Resistance and Dervish Movement sparked the beginning one of the longest anti-colonial struggles on the continent.
Mohammed Abdullah Hassan's Dervish movement spread into Somalia and successfully repulsed the British Empire four times, forcing them to retreat to the coastal region, but the Dervishes were finally defeated in 1920 by British airpower.

### Banadir Resistance

In the 1890s, the Italian occupation of Marka sparked the beginning and outrage among the Bimal clan, many of them joined the Bimal resistance against Italy. An Italian resident of the city, Giacomo Trevis, was assassinated in 1904. In response Italy occupied the port town of Jazira about 30 miles south of Mogadishu. In response Bimal leaders called for a grand conference mobilizing the Banadiri clans, thus it came to eventually be known as the Banadir Resistance. The resistance was spearheaded by Sheikh Abdi Gafle and Ma’alin Mursal Abdi Yusuf; two prominent local Islamic teachers in Marka from the Bimal clan. The resistance, albeit clan-based initially transformed into one with a religious fervour, mainly Bimal, (but also later on some of the Wa’dan, Hintire and other clans of the Geledi confederation joined).

### Dervish Movement

News of the incident that sparked the Dervish rebellion and the 21 years disturbance according to the consul-general James Hayes Sadler was spread by Sultan Nur of the Habr Yunis. The incident in question was that of a group of Somali children that were converted to Christianity and adopted by the French Catholic Mission at Berbera in 1899. Whether Sultan Nur experienced the incident first hand or whether he was told of it is not clear but what is known is that he propagated the incident in the Tariqa at Kob Fardod in June 1899, precipitating the religious rebellion that later morphed into the Somali Dervish. In one of his letters to Sultan Deria in 1899, Hassan said that the British "have destroyed our religion and made our children their children" alluding to Sultan Nur's incident with the Roman French Mission at Berbera. The Dervish soon emerged as an opposition of the Christian activities, defending their version of Islam against the Christian mission. In several of his poems and speeches, Hassan insisted that the British and the Christian Ethiopians in league with the British were bent upon plundering the political and religious freedom of the Somali nation. He soon emerged as "a champion of his country's political and religious freedom, defending it against all Christian invaders." Hassan issued a religious ordinance that any Somali national who did not accept the goal of unity of Somalia and would not fight under his leadership would be considered as kafir or gaal. He soon acquired weapons from the Ottoman Empire, Sudan, and other sympathetic Muslim countries, and appointed ministers and advisers to administer different areas or sectors of Somalia. In addition, Hassan gave a clarion call for Somali unity and independence, in the process organizing his follower-warriors. His Dervish movement had an essentially military character, and the Dervish movement was fashioned on the model of a Salihiya brotherhood. It was characterized by a rigid hierarchy and centralization. Hassan threatened to drive the Christians into the sea; he committed the first attack by launching his first major military offensive with his 1,500 Dervish equipped with 20 modern rifles on the British soldiers stationed in the region.
He repulsed the British in four expeditions and had favorable diplomatic relations with the Central Powers of the Ottoman and German Empires.

## 20th century

In 1920, the Dervish movement collapsed after intensive British aerial bombardments, and Dervish territories were subsequently turned into a protectorate. The dawn of fascism in the early 1920s heralded a change of strategy for Italy, as the north-eastern sultanates were soon to be forced within the boundaries of La Grande Somalia according to the plan of Fascist Italy. With the arrival of Governor Cesare Maria De Vecchi on 15 December 1923, things began to change for that part of Somaliland. Italy had access to these areas under the successive protection treaties, but not direct rule. The Fascist government had direct rule only over the Benadir territory Given the defeat of the Dervish movement in the early 1920s and the rise of fascism in Europe, on 10 July 1925, Mussolini gave the green light to De Vecchi to start the takeover of the north-eastern sultanates. Everything was to be changed and the treaties abrogated.
Governor De Vecchi's first plan was to disarm the sultanates. But, before the plan could be carried out, there had to be sufficient Italian troops in both sultanates. To make the enforcement of his plan more viable, he began to reconstitute the old Somali police corps, the Corpo Zaptié, as a colonial force.
In preparation for the invasion plan of the sultanates, the Alula Commissioner, E. Coronaro received orders in April 1924 to carry out a reconnaissance on the territories targeted for invasion. In spite of the 40-year Italian relationship with the sultanates, Italy did not have adequate knowledge of the geography. During this time, the Stefanini-Puccioni geological survey was scheduled to take place, so it was a good opportunity for the expedition of Coronaro to join with this.
Coronaro's survey concluded that the Ismaan Sultanate (Majeerteen) depended on sea traffic, therefore, if this were blocked, any resistance that could be mounted after the invasion of the sultanate would be minimal. As the first stage of the invasion plan, Governor De Vecchi ordered the two Sultanates to disarm. The reaction of both sultanates was to object, as they felt the policy was in breach of the protectorate agreements. The pressure engendered by the new development forced the two rival sultanates to settle their differences over possession of Nugaal, and form a united front against their common enemy.
The Sultanate of Hobyo was different from that of the Majeerteen in terms of its geography and the pattern of the territory. It was founded by Yusuf Ali Kenadid in the middle of the 19th century in central Somalia. Its jurisdiction stretched from Ceeldheer (El Dher) through to Dhusamareb in the south-west, from Galladi to Galkayo in the west, from Jariban to Garaad in the north-east, and the Indian Ocean in the east.
By 1 October, De Vecchi's plan was to go into action. The operation to invade Hobyo started in October 1925 . Columns of the new Zaptié began to move towards the sultanate. Hobyo, Ceelbuur (El Buur), Galkayo, and the territory between were completely overrun within a month. Hobyo was transformed from a sultanate into an administrative region. Sultan Yusuf Ali surrendered. Nevertheless, soon suspicions were aroused as Trivulzio, the Hobyo commissioner, reported movement of armed men towards the borders of the sultanate before the takeover and after. Before the Italians could concentrate on the Majeerteen, they were diverted by new setbacks. On 9 November, the Italian fear was realized when a mutiny, led by one of the military chiefs of Sultan Ali Yusuf, Omar Samatar, recaptured El Buur. Soon the rebellion expanded to the local population. The region went into revolt as El-Dheere also came under the control of Omar Samatar. The Italian forces tried to recapture El Buur, but they were repulsed. On 15 November, the Italians retreated to Bud Bud and on the way they were ambushed and suffered heavy casualties.
While a third attempt was in the last stages of preparation, the operation's commander, Lieutenant-Colonel Splendorelli, was ambushed between Bud Bud and Buula Barde. He and some of his staff were killed. As a consequence of the death of the commander of the operations and the effect of two failed operations intended to overcome the El Buur mutiny, the spirit of Italian troops began to wane. The Governor took the situation seriously and, to prevent any more failure, he requested two battalions from Eritrea to reinforce his troops, and assumed lead of the operations. Meanwhile, the rebellion was gaining sympathy across the country, and as far afield as Western Somalia.
The fascist government was surprised by the setback in Hobyo. The whole policy of conquest was collapsing under its nose. The El-Buur episode drastically changed the strategy of Italy as it revived memories of the Adwa fiasco when Italy had been defeated by Abyssinia. Furthermore, in the Colonial Ministry in Rome, senior officials distrusted the Governor's ability to deal with the matter. Rome instructed De Vecchi that he was to receive the reinforcement from Eritrea, but that the commander of the two battalions was to temporarily assume the military command of the operations and De Vecchi was to stay in Mogadishu and confine himself to other colonial matters. In the case of any military development, the military commander was to report directly to the Chief of Staff in Rome.
While the situation remained perplexing, De Vecchi moved the deposed sultan to Mogadishu. Fascist Italy was poised to re-conquer the sultanate by whatever means. To maneuver the situation within Hobyo, they even contemplated the idea of reinstating Ali Yusuf. However, the idea was dropped after they became pessimistic about the results.
To undermine the resistance, however, and before the Eritrean reinforcement could arrive, De Vecchi began to instill distrust among the local people by buying the loyalty of some of them. In fact, these tactics had better results than the military campaign had, and the resistance began gradually to wear down. Given the anarchy that would follow, the new policy was a success.
On the military front, Italian troops finally overran El Buur on 26 December 1925, and the forces of Omar Samatar were compelled to retreat to Western Somaliland.
By neutralising Hobyo, the fascists could concentrate on the Majeerteen. In early October 1924, E. Coronaro, the new Alula commissioner, presented Boqor (king) Osman Mahamuud with an ultimatum to disarm and surrender. Meanwhile, Italian troops began to pour into the sultanate in anticipation of this operation. While landing at Haafuun and Alula, the sultanate's troops opened fire on them. Fierce fighting ensued and to avoid escalating the conflict and to press the fascist government to revoke their policy, Boqor Osman tried to open a dialogue. However, he failed, and again fighting broke out between the two parties. Following this disturbance, on 7 October, the Governor instructed Coronaro to order the Sultan to surrender; to intimidate the people he ordered the seizure of all merchant boats in the Alula area. At Hafun, Arimondi bombarded and destroyed all the boats in the area.
On 13 October, Coronaro was to meet Boqor Osman at Baargaal to press for his surrender. Under siege already, Boqor Osman was playing for time. However, on 23 October, Boqor Osman sent an angry response to the Governor defying his order. Following this a full-scale attack was ordered in November. Baargaal was bombarded and destroyed to the ground. This region was ethnically compact, and was out of range of direct action by the fascist government of Muqdisho. The attempt of the colonizers to suppress the region erupted into explosive confrontation. The Italians were meeting fierce resistance on many fronts. In December 1925, led by the charismatic leader Hersi Boqor, son of Boqor Osman, the sultanate forces drove the Italians out of Hurdia and Hafun, two strategic coastal towns. Another contingent attacked and destroyed an Italian communications centre at Cape Guardafui, at the tip of the Horn. In retaliation the Bernica and other warships were called on to bombard all main coastal towns of the Majeerteen. After a violent confrontation Italian forces captured Eyl (Eil), which until then had remained in the hands of Hersi Boqor. In response to the unyielding situation, Italy called for reinforcements from their other colonies, notably Eritrea. With their arrival at the closing of 1926, the Italians began to move into the interior where they had not been able to venture since their first seizure of the coastal towns. Their attempt to capture Dharoor Valley was resisted, and ended in failure.
De Vecchi had to reassess his plans as he was being humiliated on many fronts. After one year of exerting full force he could not yet manage to gain a result over the sultanate. In spite of the fact that the Italian navy sealed the sultanate's main coastal entrance, they could not succeed in stopping them from receiving arms and ammunition through it. It was only early 1927 when they finally succeeded in shutting the northern coast of the sultanate, thus cutting arms and ammunition supplies for the Majeerteen. By this time, the balance had tilted to the Italians' side, and in January 1927 they began to attack with a massive force, capturing Iskushuban, at the heart of the Majeerteen. Hersi Boqor unsuccessfully attacked and challenged the Italians at Iskushuban. To demoralise the resistance, ships were ordered to target and bombard the sultanate's coastal towns and villages. In the interior, the Italian troops confiscated livestock. By the end of the 1927, the Italians had taken full control of the sultanate. Hersi Boqor and his troops retreated to Ethiopia in order to rebuild their forces, but were unable to retake their territories, effectively ending the Campaign of the Sultanates.

## "Somalia Italiana" and World War II

On 9 May 1936, Mussolini proclaimed the creation of the Italian Empire, calling it the Africa Orientale Italiana (A.O.I.) and formed by Ethiopia, Eritrea and Italian Somaliland (called officially "Somalia italiana"). The Italians added to Somalia the Ogaden (taken from the conquered Ethiopia).
In the 1930s the Italians made many new investments in infrastructure in the region, such as the Strada Imperiale ("imperial road") between Addis Ababa and Mogadishu and the railway Mogadishu-Villabruzzi of 114 km.
Over the course of Italian Somaliland's existence, many Somali troops fought in the so-called Regio Corpo Truppe Coloniali. The soldiers were enrolled not only as regular soldiers (like in the two Italian Somali Divisions (101 and 102)) but also as Dubats, Zaptié and Bande irregolari. During World War II, these troops were regarded as a wing of the Italian Army's Infantry Division, as was the case in Libya and Eritrea. The Zaptié provided a ceremonial escort for the Italian Viceroy (Governor) as well as the territorial police. There were already more than one thousand such soldiers in 1922.
In 1941, in Italian Somaliland and Ethiopia, 2,186 Zaptié plus an additional 500 recruits under training officially constituted a part of the Carabinieri. They were organised into a battalion commanded by Major Alfredo Serranti that defended Culqualber (Ethiopia) for three months until this military unit was destroyed by the Allies. After heavy fighting, the Somali troops and the Italian Carabinieri received full military honors from the British.
In the first half of 1940, there were 22,000 Italians living in Somalia and the colony was one of the most developed in East Africa in terms of the standard of living of the colonists and of the Somalis, mainly in the urban areas. More than 10,000 Italians were living in Mogadishu, the administrative capital of the Africa Orientale Italiana, and new buildings were erected in the Italian architectural tradition. By 1940, the Villaggio Duca degli Abruzzi (now Jowhar) had a population of 12,000 people, of whom nearly 3,000 were Italian Somalis, and enjoyed a notable level of development with a small manufacturing area with agricultural industries (sugar mills, etc.).
In the second half of 1940, Italian troops invaded British Somaliland and ejected the British. The Italians also occupied parts of the British East Africa Protectorate bordering Jubaland around the towns of Moyale and Buna.
Mussolini boasted in front of a group of Somalis leaders -in late summer 1940- that he had created the "Greater Somalia" (dreamed by the Somali population) after the union of British Somaliland to his Somalia Governorate.
* Italian Somalia
* Mogadiscio cathedral
* Cinema Italia in Mogadiscio, 1937
* Fiat building in Mogadiscio, 1940
* Italian stamp from Mogadiscio
* Governor's palace in Mogadiscio

## Independence

During World War II, Britain regained control of British Somaliland and conquered Italian Somaliland, administering both militarily as protectorates. In November 1945, during the Potsdam Conference, the United Nations granted Italy trusteeship of Italian Somaliland, but only under close supervision and on the condition—first proposed by the Somali Youth League (SYL) and other nascent Somali political organizations, such as Hizbia Digil Mirifle Somali (HDMS) and the Somali National League (SNL)—that Somalia achieve independence within ten years. British Somaliland remained a protectorate of Britain until 1960.
To the extent that Italy held the territory by UN mandate, the trusteeship provisions gave the Somalis the opportunity to gain experience in political education and self-government. These were advantages that British Somaliland, which was to be incorporated into the new Somali state, did not have. Although, in the 1950s, British colonial officials attempted, through various administrative development efforts, to make up for past neglect, the protectorate stagnated. The disparity between the two territories in economic development and political experience would cause serious difficulties when it came time to integrate the two parts. Britain included the proviso that the Somali nomads would retain their autonomy, but Ethiopia immediately claimed sovereignty over them. This prompted an unsuccessful bid by Britain in 1956 to buy back the Somali lands it had turned over. Britain also granted administration of the almost exclusively Somali-inhabited Northern Frontier District (NFD) to Kenyan nationalists despite an informal plebiscite demonstrating the overwhelming desire of the region's population to join the newly formed Somali Republic.
A referendum was held in neighboring Djibouti (then known as French Somaliland) in 1958, on the eve of Somalia's independence in 1960, to decide whether or not to join the Somali Republic or to remain with France. The referendum turned out in favour of a continued association with France, largely due to a combined yes vote by the sizable Afar ethnic group and resident Europeans. There was also allegations of widespread vote rigging, with the French expelling thousands of Somalis before the referendum reached the polls. The majority of those who voted "no" were Somalis who were strongly in favour of joining a united Somalia, as had been proposed by Mahmoud Harbi, Vice President of the Government Council. Harbi was killed in a plane crash two years later. Djibouti finally gained its independence from France in 1977, and Hassan Gouled Aptidon, a Somali who had campaigned for a yes vote in the referendum of 1958, eventually wound up as Djibouti's first president (1977–1991).
On 1 July 1960, the two territories united to form the Somali Republic, albeit within boundaries drawn up by Italy and Britain. A government was formed by Abdullahi Issa Mohamud and Muhammad Haji Ibrahim Egal and other members of the trusteeship and protectorate governments, with the Speaker of the Somali Union Act Haji Bashir Ismail Yusuf as President of the Somali National Assembly, Aden Abdullah Osman Daar as President of Somali Republic, and Abdirashid Ali Shermarke as Prime Minister (later to become president from 1967 to 1969). On 20 July 1961 and through a popular referendum, the people of Somalia ratified a new constitution, which was first drafted in 1960. In 1967, Muhammad Haji Ibrahim Egal became Prime Minister, a position to which he was appointed by Shermarke. Egal would later become the President of the autonomous Somaliland region in northwestern Somalia.
On 15 October 1969, while paying a visit to the northern town of Las Anod, Somalia's then President Abdirashid Ali Shermarke was shot dead by a policeman. His assassination was quickly followed by a military coup d'état on 21 October 1969 (the day after his funeral), in which the Somali Army seized power without encountering armed opposition – essentially a bloodless takeover. The putsch was spearheaded by Major General Mohamed Siad Barre, who at the time commanded the army.

## Somali Democratic Republic
### Supreme Revolutionary Council

Alongside Barre, the Supreme Revolutionary Council (SRC) that assumed power after President Sharmarke's assassination was led by Lieutenant Colonel Salaad Gabeyre Kediye and Chief of Police Jama Korshel. Kediye officially held the title of "Father of the Revolution," and Barre shortly afterwards became the head of the SRC. The SRC subsequently renamed the country the Somali Democratic Republic, dissolved the parliament and the Supreme Court, and suspended the constitution.
The revolutionary army established large-scale public works programs and successfully implemented an urban and rural literacy campaign, which helped dramatically increase the literacy rate. In addition to a nationalization program of industry and land, the new regime's foreign policy placed an emphasis on Somalia's traditional and religious links with the Arab world, eventually joining the Arab League (AL) in 1974. That same year, Barre also served as chairman of the Organization of African Unity (OAU), the predecessor of the African Union (AU).
In July 1976, Barre's SRC disbanded itself and established in its place the Somali Revolutionary Socialist Party (SRSP), a one-party government based on scientific socialism and Islamic tenets. The SRSP was an attempt to reconcile the official state ideology with the official state religion by adapting Marxist precepts to local circumstances. Emphasis was placed on the Muslim principles of social progress, equality and justice, which the government argued formed the core of scientific socialism and its own accent on self-sufficiency, public participation and popular control, as well as direct ownership of the means of production. While the SRSP encouraged private investment on a limited scale, the administration's overall direction was essentially communist.

### Ogaden War

In July 1977, the Ogaden War broke out after Barre's government sought to incorporate the predominantly Somali-inhabited Ogaden region of Ethiopia into a Pan-Somali Greater Somalia. In the first week of the conflict, Somali armed forces seized the southern and central parts of the Ogaden. The units in the Godey Front were led by Colonel Abdullahi Ahmed Irro. For most of the war, the Somali army scored continuous victories on the Ethiopian army, following it as far as Sidamo. By September 1977, Somalia controlled 90% of the Ogaden and captured strategic cities such as Jijiga and put heavy pressure on Dire Dawa, threatening the train route from the latter city to Djibouti. After the siege of Harar, a massive unprecedented Soviet intervention consisting of 20,000 Cuban forces and several thousand Soviet experts came to the aid of Ethiopia's communist Derg regime. By 1978, the Somali troops were ultimately pushed out of the Ogaden. This shift in support by the Soviet Union motivated the Barre government to seek allies elsewhere. It eventually settled on the Soviets' Cold War arch-rival, the United States, which had been courting the Somali government for some time. All in all, Somalia's initial friendship with the Soviet Union and later partnership with the United States enabled it to build the largest army in Africa.

### Isaaq genocide

Isaaq genocide was the systematic, state-sponsored massacre of Isaaq civilians between 1987 and 1989 by the Somali Democratic Republic under the dictatorship of Siad Barre. The number of civilian deaths in this massacre is estimated to be between 50,000 and 100,000 according to various sources, whilst local reports estimate the total civilian deaths to be upwards of 200,000 Isaaq civilians. This genocide also included the levelling and complete destruction of the second and third largest cities in Somalia, Hargeisa (which was 90 percent destroyed) and Burao (70 per cent destroyed) respectively, and had caused up to 500,000 Somalis (primarily of the Isaaq clan) to flee their land and cross the border to Hartasheikh in Ethiopia as refugees, in what was described as "one of the fastest and largest forced movements of people recorded in Africa", and resulted in the creation of the world's largest refugee camp then (1988), with another 400,000 being displaced. The scale of destruction led to Hargeisa being known as the 'Dresden of Africa'. The killings happened during the Somali Civil War and have been referred to as a "forgotten genocide".

### Rebellion

A new constitution was promulgated in 1979 under which elections for a People's Assembly were held. However, Barre's Somali Revolutionary Socialist Party politburo continued to rule. In October 1980, the SRSP was disbanded, and the Supreme Revolutionary Council was re-established in its place.
In May 1986, President Barre suffered serious injuries in a life-threatening automobile accident near Mogadishu, when the car that was transporting him smashed into the back of a bus during a heavy rainstorm. He was treated in a hospital in Saudi Arabia for head injuries, broken ribs and shock over a period of a month. Lieutenant General Mohamed Ali Samatar, then Vice President, subsequently served as de facto head of state for the next several months. Although Barre managed to recover enough to present himself as the sole presidential candidate for re-election over a term of seven years on 23 December 1986, his poor health and advanced age led to speculation about who would succeed him in power. Possible contenders included his son-in-law General Ahmed Suleiman Abdille, who was at the time the Minister of the Interior, in addition to Barre's Vice President Lt. Gen. Samatar.
By that time, Barre's government had become increasingly unpopular. Many Somalis had become disillusioned with life under military dictatorship. The regime was weakened further in the 1980s as the Cold War drew to a close and Somalia's strategic importance was diminished. The government became increasingly totalitarian, and resistance movements, encouraged by Ethiopia, sprang up across the country, eventually leading to the Somali Civil War. Among the militia groups were the Somali Salvation Democratic Front (SSDF), United Somali Congress (USC), Somali National Movement (SNM) and the Somali Patriotic Movement (SPM), together with the non-violent political oppositions of the Somali Democratic Movement (SDM), the Somali Democratic Alliance (SDA) and the Somali Manifesto Group (SMG).

## Somali Civil War

With the political situation deteriorating, Barre's long-standing government in 1991 eventually collapsed under the pressure. The national army disbanded shortly afterwards.
United Nations Security Council Resolution 794 was unanimously passed on 3 December 1992, which approved a coalition of United Nations peacekeepers led by the United States. Forming the Unified Task Force (UNITAF), the force was tasked with assuring security until humanitarian efforts aimed at stabilizing the situation were transferred to the UN. Landing in 1993, the UN peacekeeping coalition started the two-year United Nations Operation in Somalia II (UNOSOM II) primarily in the south to provide humanitarian relief.
Some militias that had seized power after the oust of Barre regime's interpreted the UN troops' presence as a threat to their hegemony. Consequently, several gun battles took place in Mogadishu between local gunmen and peacekeepers. Among these was the Battle of Mogadishu, an unsuccessful attempt by US troops to apprehend faction leader Mohamed Farah Aidid. The UN soldiers eventually withdrew altogether from the country on 3 March 1995, having incurred more significant casualties.

## Decentralization

Following the outbreak of the civil war and the ensuing collapse of the central government, Somalia's residents reverted to local forms of conflict resolution, either secular, traditional or Islamic law, with a provision for appeal of all sentences. The legal structure in Somalia is thus divided along three lines: civil law, religious law and customary law.

### Civil law

While Somalia's formal judicial system was largely destroyed after the fall of the Siad Barre regime, it was later gradually rebuilt and administered under different regional governments, such as the autonomous Puntland and Somaliland macro-regions. In the case of the later Transitional Federal Government, a new interim judicial structure was formed through various international conferences.
Despite some significant political differences between them, all of these administrations share similar legal structures, much of which are predicated on the judicial systems of previous Somali administrations. These similarities in civil law include:
* a charter which affirms the primacy of Muslim shari'a or religious law, although in practice shari'a is applied mainly to matters such as marriage, divorce, inheritance, and civil issues. The charter guarantees respect for universal standards of human rights to all subjects of the law. It also assures the independence of the judiciary, which in turn is protected by a judicial committee;
* a three-tier judicial system including a supreme court, a court of appeals, and courts of first instance (either divided between district and regional courts, or a single court per region); and
* the laws of the civilian government which were in effect prior to the military coup d'état that saw the Barre regime into power remain in force until the laws are amended.

### Shari'a

Islamic shari'a has traditionally played a significant part in Somali society. In theory, it has served as the basis for all national legislation in every Somali constitution. In practice, however, it only applied to common civil cases such as marriage, divorce, inheritance and family matters. This changed after the start of the civil war when a number of new shari'a courts began to spring up in many different cities and towns across the country. These new shari'a courts serve three functions; namely, to pass rulings in both criminal and civil cases, to organize a militia capable of arresting criminals, and to keep convicted prisoners incarcerated.
The shari'a courts, though structured along simple lines, feature a conventional hierarchy of a chairman, vice-chairman and four judges. A police force that reports to the court enforces the judges' rulings, but also helps settle community disputes and apprehend suspected criminals. In addition, the courts manage detention centers where criminals are kept. An independent finance committee is also assigned the task of collecting and managing tax revenue levied on regional merchants by the local authorities.

### Xeer

Somalis have for centuries practiced a form of customary law, called Xeer (pronounced /ħeːr/). Xeer is a polycentric legal system where there is no monopolistic institution or agent that determines what the law should be or how it should be interpreted.
The Xeer legal system is assumed to have developed exclusively in the Horn of Africa since approximately the 7th century. There is no evidence that it developed elsewhere or was greatly influenced by any foreign legal system. Its legal terminology is practically devoid of loan words from foreign languages, suggesting that it is truly indigenous.
The Xeer legal system also requires a certain amount of specialization of different functions within the legal framework. Thus, one can find odayaal (judges), xeerbogeyaal (jurists), guurtiyaal (detectives), garxajiyaal (attorneys), markhaatiyal (witnesses) and waranle (police officers) to enforce the law.
Xeer is defined by a few fundamental tenets that are immutable and which closely approximate the principle of jus cogens in international law: These precepts include: a) payment of blood money (locally referred to as diya) for libel, theft, physical harm, rape and death, as well as supplying assistance to relatives; b) assuring good inter-clan relations by treating women justly, negotiating with "peace emissaries" in good faith, and sparing the lives of socially protected groups "Birr Magaydo," (e.g. children, women, the pious, poets, messengers, sheikhs, and guests); c) family obligations such as the payment of dowry, and sanctions for eloping; d) rules pertaining to the management of resources such as the use of pasture land, water, and other natural resources; e) providing financial support to married female relatives and newlyweds; f) donating livestock and other assets to the poor.

## Transitional period (2000–2012)
### Transitional National Government

In 2000, Abdiqasim Salad Hassan was selected as the President of the nation's new Transitional National Government (TNG), an interim administration formed to guide Somalia to its third permanent republican government.
On 10 October 2004, in a session held by the Transitional Federal Parliament (TFP), Abdullahi Yusuf Ahmed was elected as President of the succeeding Transitional Federal Government (TFG), an interim federal administrative body that he had helped establish earlier in the year. He received 189 votes from the TFG Parliament, while the closest contender, erstwhile Somali ambassador to Washington Abdullahi Ahmed Addou, got 79 votes in the third round of voting. The then incumbent President of Somalia, Abdiqasim Salad Hassan, peacefully withdrew his candidature. Ahmed was sworn in a few days later on 14 October 2004.

### Transitional Federal Institutions

The Transitional Federal Government (TFG) was the internationally recognised government of Somalia until 20 August 2012, when its tenure officially ended. It was established as one of the Transitional Federal Institutions (TFIs) of government as defined in the Transitional Federal Charter (TFC) adopted in November 2004 by the Transitional Federal Parliament (TFP).
The Transitional Federal Government officially comprised the executive branch of government, with the TFP serving as the legislative branch. The government was headed by the President of Somalia, to whom the cabinet reported through the Prime Minister. However, it was also used as a general term to refer to all three branches collectively.

### Islamic Courts Union and Ethiopian intervention

In 2006, the Islamic Courts Union (ICU), an Islamist organization, assumed control of much of the southern part of the country and promptly imposed Shari'a law. The Transitional Federal Government sought to reestablish its authority, and, with the assistance of Ethiopian troops, African Union peacekeepers and air support by the United States, managed to drive out the rival ICU and solidify its rule.
On 8 January 2007, as the Battle of Ras Kamboni raged, TFG President and founder Abdullahi Yusuf Ahmed, a former colonel in the Somali Army and decorated war hero, entered Mogadishu for the first time since being elected to office. The government then relocated to Villa Somalia in the capital from its interim location in Baidoa. This marked the first time since the fall of the Siad Barre regime in 1991 that the federal government controlled most of the country.
Following this defeat, the Islamic Courts Union splintered into several different factions. Some of the more radical elements, including Al-Shabaab, regrouped to continue their insurgency against the TFG and oppose the Ethiopian military's presence in Somalia. Throughout 2007 and 2008, Al-Shabaab scored military victories, seizing control of key towns and ports in both central and southern Somalia. At the end of 2008, the group had captured Baidoa but not Mogadishu. By January 2009, Al-Shabaab and other militias had managed to force the Ethiopian troops to retreat, leaving behind an under-equipped African Union peacekeeping force to assist the Transitional Federal Government's troops.
Owing to a lack of funding and human resources, an arms embargo that made it difficult to re-establish a national security force, and general indifference on the part of the international community, President Yusuf found himself obliged to deploy thousands of troops from Puntland to Mogadishu to sustain the battle against insurgent elements in the southern part of the country. Financial support for this effort was provided by the autonomous region's government. This left little revenue for Puntland's own security forces and civil service employees, leaving the territory vulnerable to piracy and terrorist attacks.
On 29 December 2008, Abdullahi Yusuf Ahmed announced before a united parliament in Baidoa his resignation as President of Somalia. In his speech, which was broadcast on national radio, Yusuf expressed regret at failing to end the country's seventeen-year conflict as his government had mandated to do. He also blamed the international community for its failure to support the government, and said that the speaker of parliament would succeed him in office per the Charter of the Transitional Federal Government.

### Coalition government

Between May 31 and June 9, 2008, representatives of Somalia's federal government and the moderate Alliance for the Re-liberation of Somalia (ARS) group of Islamist rebels participated in peace talks in Djibouti brokered by the former United Nations Special Envoy to Somalia, Ahmedou Ould-Abdallah. The conference ended with a signed agreement calling for the withdrawal of Ethiopian troops in exchange for the cessation of armed confrontation. Parliament was subsequently expanded to 550 seats to accommodate ARS members, which then elected Sheikh Sharif Sheikh Ahmed, the former ARS chairman, to office. President Sharif shortly afterwards appointed Omar Abdirashid Ali Sharmarke, the son of the assassinated former President Abdirashid Ali Sharmarke, as the nation's new Prime Minister.
With the help of a small team of African Union troops, the coalition government also began a counteroffensive in February 2009 to assume full control of the southern half of the country. To solidify its rule, the TFG formed an alliance with the Islamic Courts Union, other members of the Alliance for the Re-liberation of Somalia, and Ahlu Sunna Waljama'a, a moderate Sufi militia. Furthermore, Al-Shabaab and Hizbul Islam, the two main Islamist groups in opposition, began to fight amongst themselves in mid-2009.
As a truce, in March 2009, Somalia's coalition government announced that it would re-implement Shari'a as the nation's official judicial system. However, conflict continued in the southern and central parts of the country. Within months, the coalition government had gone from holding about 70% of south-central Somalia's conflict zones, territory which it had inherited from the previous Yusuf administration, to losing control of over 80% of the disputed territory to the Islamist insurgents.
On 14 October 2010, diplomat Mohamed Abdullahi Mohamed (Farmajo) was appointed the new Prime Minister of Somalia. The former Premier Omar Abdirashid Ali Sharmarke resigned the month before following a protracted dispute with President Sharif over a proposed draft constitution.
Per the Transitional Federal Government's (TFG) Charter, Prime Minister Mohamed named a new Cabinet on 12 November 2010, which has been lauded by the international community. As had been expected, the allotted ministerial positions were significantly reduced in numbers, with only 18 administrative posts unveiled versus the previous government's bloated 39 portfolios. Only two Ministers from the previous Cabinet were reappointed: Hussein Abdi Halane, the former Minister of Finance and a well-regarded figure in the international community, was put in charge of a consolidated Ministry of Finance and Treasury; and Dr. Mohamud Abdi Ibrahim was reassigned to the Ministry of Commerce and Industry. Ahlu Sunna Waljama'a, a moderate Sufi group and an important military ally of the TFG, was also accorded the key Interior and Labour ministries. The remaining ministerial positions were largely assigned to technocrats new to the Somali political arena.
In its first 50 days in office, Prime Minister Mohamed's new administration completed its first monthly payment of stipends to government soldiers, and initiated the implementation of a full biometric register for the security forces within a window of four months. Additional members of the Independent Constitutional Commission were also appointed to engage Somali constitutional lawyers, religious scholars and experts in Somali culture over the nation's upcoming new constitution, a key part of the government's Transitional Federal Tasks. In addition, high level federal delegations were dispatched to defuse clan-related tensions in several regions. According to the prime minister of Somalia, to improve transparency, Cabinet ministers fully disclosed their assets and signed a code of ethics.
An Anti-Corruption Commission with the power to carry out formal investigations and to review government decisions and protocols was also established so as to more closely monitor all activities by public officials. Furthermore, unnecessary trips abroad by members of government were prohibited, and all travel by ministers now require the Premier's consent. A budget outlining 2011's federal expenditures was also put before and approved by members of parliament, with the payment of civil service employees prioritized. In addition, a full audit of government property and vehicles is being put into place. On the war front, the new government and its AMISOM allies also managed to secure control of 60% of Mogadishu, where 80% of the capital's population now lives. According to the African Union and Prime Minister Mohamed, with increasing troop strength the pace of territorial gains is expected to greatly accelerate.
On 19 June 2011, Mohamed Abdullahi Mohamed resigned from his position as Prime Minister of Somalia. Part of the controversial Kampala Accord's conditions, the agreement would also see the mandates of the President, the Parliament Speaker and Deputies extended until August 2012, after which point new elections are to be organized. Abdiweli Mohamed Ali, Mohamed's former Minister of Planning and International Cooperation, was later named permanent Prime Minister.

## Federal Republic of Somalia (since 2012)

As part of the official "Roadmap for the End of Transition", a political process which provided clear benchmarks leading toward the formation of permanent democratic institutions in Somalia, the Transitional Federal Government's interim mandate ended on 20 August 2012. The Federal Parliament of Somalia was concurrently inaugurated, ushering in the Federal Government of Somalia, the first permanent central government in the country since the start of the civil war.
On 10 September 2012, parliament elected Hassan Sheikh Mohamud as the new President of Somalia. President Mohamud later appointed Abdi Farah Shirdon as the new Prime Minister on 6 October 2012, who was succeeded in office by Abdiweli Sheikh Ahmed on 21 December 2013.
In April 2013, Hassan resumed national reconciliation talks between the central government in Mogadishu and the secessionist Somaliland authorities. Organized by the government of Turkey in Ankara, the meeting ended with a signed agreement between Hassan and Ahmed Mahamoud Silanyo, President of Somaliland, agreeing to allocate fairly to the Somaliland its portion of the development aid earmarked for Somalia as a whole and to cooperate on security.
In August 2013, the Somali federal government signed a national reconciliation agreement in Addis Ababa with the autonomous Jubaland administration based in southern Somalia. Endorsed by the federal State Minister for the Presidency Farah Abdulkadir on behalf of Hassan, the pact was brokered by the Foreign Ministry of Ethiopia and came after protracted bilateral talks. Under the terms of the agreement, Jubaland will be administered for a two-year period by a Juba Interim Administration and led by the region's incumbent president, Ahmed Mohamed Islam (Madobe). The regional president will serve as the chairperson of a new Executive Council, to which he will appoint three deputies. Management of Kismayo's seaport and airport will also be transferred to the Federal Government after a period of six months, and revenues and resources generated from these infrastructures will be earmarked for Jubaland's service delivery and security sectors as well as local institutional development. Additionally, the agreement includes the integration of Jubaland's military forces under the central command of the Somali National Army (SNA), and stipulates that the Juba Interim Administration will command the regional police. UN Special Envoy to Somalia Nicholas Kay hailed the pact as "a breakthrough that unlocks the door for a better future for Somalia,"
In August 2014, the Somali-government-led Operation Indian Ocean was launched against the Al-Shabaab militant group to clean up the remaining insurgent-held pockets in the countryside.
On 17 December 2014, former Premier Omar Abdirashid Ali Sharmarke was reappointed Prime Minister.
In February 2015, Hassan chaired a three-day consultation forum in Mogadishu with presidents Abdiweli Mohamed Ali, Ahmed Mohamed Islam and Sharif Hassan Sheikh Adan of the Puntland, Jubaland and South West State regional administrations, respectively. Under the rubric of the New Deal for Somalia, Hassan held additional national reconciliation talks with the regional leaders in Garowe in April and May of the year. The officials therein signed a seven-point agreement in Garowe authorizing the immediate deployment of the 3,000 troops from Puntland toward the Somali National Army. They also agreed to integrate soldiers from the other regional states into the SNA.
On 8 February 2017, Somali MPs elected Ex-Prime Minister Mohamed Abdullahi "Farmajo" Mohamed in a surprise result. On 23 February 2017, President Mohamed appointed former humanitarian worker and businessman Hassan Khaire as his Prime Minister.
When President Mohamed Abdullahi Mohamed's term expired in February 2021, dates had not been set for the election of a successor, and fighting subsequently broke out in Mogadishu. This fighting continued until May 2021, when the government and opposition agreed to hold elections within 60 days; after further negotiation, the presidential election was scheduled for October 10.
In December 2021, Mohamed revoked the authority of prime minister Mohamed Hussein Roble to organize upcoming elections and suggested that a new committee should be formed to oversee them. This prompted Roble to accuse Mohamed of sabotaging the electoral process on 26 December 2021. On 27 December, Mohamed announced that he was suspending Roble over alleged obstruction of corruption allegations.
All of Mohamed Abdullahi Farmajo accusations described obstructing the elections, as the outgoing president had plunged the country into chaos because of his greed to extend his power
On 15 May 2022, Hassan Sheikh Mohamud was again elected as President of Somalia.
On June 25, Prime Minister Mohamed Hussein Roble's work came to an end, and Hamza Abdi Barre currently serves as the Prime Minister of Somalia beside President Hassan Sheikh Mohamud.

## Timelines
### Ancient

   * c. 2350 BC: The Land of Punt establishes trade with the Ancient Egyptians.
   * 1st century AD: City states on the Somali coast are active in commerce trading with Greek, and later Roman merchants.

### Muslim era

   * 630s–900: Somalis adopt Islam.
   * 9th century – 13th century: Adal Kingdom.
   * 10th century – 16th century: Sultanate of Mogadishu.
   * 1285–1415: The rise and fall of the Sultanate of Ifat.
   * 1200s – late 1600s: The rise and fall of the Ajuran Sultanate.
   * 1300–1400: Mogadishu, Zeila and Barawe are visited by Ibn Battuta and Zheng He.
   * 1415–1559: The rise and fall of the Adal Sultanate.
   * 1528–1535: Jihad against Ethiopia led by Ahmad ibn Ibrihim al-Ghazi (also called Ahmed Gurey and Ahmed Gran; "the Left-handed").
   * late 17th – late 19th century: Berbera's domination in Gulf of Aden trade, Haji Sharmarke Ali Saleh, governor of Zeila, Berbera and Tadjourah, and Sultanate of the Geledi.
   * mid-18th century – 1929: Majeerteen Sultanate also known as Migiurtinia/Majeerteenia.
   * 1878–1927: Sultanate of Hobyo.

### Modern era

   * 20 July 1887 : British Somaliland protectorate (in the north) subordinated to Aden to 1905.
   * 3 August 1889: Benadir Coast Italian Protectorate (in the northeast), (unoccupied until May 1893).
   * 1895–1920: Darawiish
   * 16 March 1905: Italian Somaliland colony (in the northeast, central and south).
   * July 1910: Italian Somaliland a crown colony
   * 1920: The Dervish leader Mohammed Abdullah Hassan dies in Imey and the longest and bloodiest colonial resistance war in Africa ends.
   * 15 January 1935: Italian Somaliland, part of Italian East Africa along with Italian Eritrea (and from 1936 Ethiopia).
   * 1 June 1936: The Somalia Governorate is established as one of the six governorates of Italian East Africa.

### World War II

   * 18 August 1940: Italian occupation of British Somaliland.
   * February 1941: British administration of Italian Somaliland.

### Independence and Cold War

   * 1 April 1950: Italian Somaliland becomes a United Nations trust territory administration, the Trust Territory of Somalia, which is promised independence within 10 years.
   * 26 June 1960: British Somaliland is granted independence as the State of Somaliland, with the understanding that it is to reunite with Italian Somaliland.
   * 1 July 1960: Reunification of British Somaliland with Italian Somaliland to form the Somali Republic.
   * 1 July 1960: First president of Somali National Assembly, Speaker of the Somali Union Act. Haji Bashir Ismail Yusuf.
   * 1 July 1960 – 1967: Presidency of Aden Abdullah Osman Daar
   * 1967–1969: Presidency of Abdirashid Ali Sharmarke; assassinated by one of the policemen assigned to his protection.
   * 21 October 1969: Somali Democratic Republic.
   * 1969–1991: Siad Barre, leader of the Supreme Revolutionary Council, rises to power.
   * 23 July 1977 – 15 March 1978: Ogaden War.
   * 1982: 1982 Ethiopian–Somali Border War.
   * 1986: Fall of Barre government.
   * 1991: Somaliland declares independence from Somalia.