According to the Periplus of the Erythraean Sea, maritime trade connected Somalis in the Mogadishu area with other communities along the Indian Ocean coast as early as the 1st century CE With Muslim traders from the Arabian Peninsula arriving circa 900 CE, Mogadishu was well-suited to become a regional center for commerce.
The name "Mogadishu" is held to be derived from the Arabic مقعد الشاه Maq'ad-u-Shah ("The seat of the Shah"), a reflection of the city's early Persian influence.
For many years, Mogadishu stood as the pre-eminent city in the بلاد البربر Bilad-ul-Barbar ("Land of the Berbers"), which was the medieval Arabic term for the Horn of Africa. Following his visit to the city, the 12th century Syrian historian Yaqut al-Hamawi wrote that it was inhabited by dark-skinned Berbers, the ancestors of the modern Somalis.
The Sultanate of Mogadishu developed with the immigration of Emozeidi Arabs, a community whose earliest presence dates back to the 9th or 10th century. This evolved into the Muzaffar dynasty, a joint Somali-Arab federation of rulers, and Mogadishu became closely linked with the powerful Somali Ajuuraan State.
By the time of the Moroccan traveller Ibn Battuta's appearance on the Somali coast in 1331, the city was at the zenith of its prosperity. Battuta described Mogadishu as "an exceedingly large city" with many rich merchants, which was famous for its high quality fabric that it exported to Egypt, among other places. He added that the city was ruled by a Somali Sultan originally from Berbera in northern Somalia who spoke both Somali (referred to by Battuta as Mogadishan, the Benadir dialect of Somali) and Arabic with equal fluency. The Sultan also had a retinue of wazirs (ministers), legal experts, commanders, royal eunuchs, and other officials at his beck and call.
The Portuguese would later attempt to occupy the city, but never managed to take it. The Hawiye Somali, however, were successful in defeating the Ajuuraan State and bringing about the end of Muzaffar rule.
In 1892, Ali bin Said leased the city to Italy. Italy purchased the city in 1905 and made Mogadishu the capital of the newly-established Italian Somaliland. After World War I, the surrounding territory came under Italian control with some resistance.
Thousands of Italian colonists moved to live in Mogadishu and founded small manufacturing companies. They also developed some agricultural areas around the capital such as the Villaggio duca degli Abruzzi and the Genale.
In the 1930s, new buildings and avenues were built. A 114 km narrow-gauge railway was laid from Mogadishu to Jowhar, then called "Villaggio Duca degli Abruzzi". An asphalted road, the Strada Imperiale was also constructed, intended to link Mogadishu to Addis Ababa.
Mogadishu remained the capital of Italian Somaliland throughout the existence of the latter, and became the capital of independent Somalia in 1960.
Rebel forces entered and took the city in 1990, forcing the then President of Somalia, Mohamed Siad Barre, to flee in 1991 to Kenya. One faction proclaimed Ali Mahdi Muhammad president, another Mohamed Farrah Aidid. A contingent of United States Marines landed near Mogadishu on December 9, 1992 to spearhead the United Nations peacekeeping forces during Operation Restore Hope, in which Pakistan, Italy and Malaysia also participated.
In the wake of Operation Restore Hope, further US peacekeeping continued, until, on October 4, 1993, American forces were finally evacuated to the UN's Pakistani base by an armored convoy along the so-called "Mogadishu Mile" during the Battle of Mogadishu (1993). In that operation alone, 18 U.S. soldiers died and 73 were injured, while two US Black Hawk helicopters were shot down and three further MH-60s put out of action. After the battle, one or more US casualties of the conflict were dragged through the streets of Mogadishu by crowds of local civilians and SNA forces. The Malaysian forces lost one soldier and had seven injured, while the Pakistanis suffered two injured. Casualties on the Somali side were heavy, with estimates on fatalities ranging from 500 to over 2,000 people. The Somali casualties were a mixture of militiamen and local civilians. Somali civilians suffered heavy casualties due to the dense urban character of that portion of Mogadishu. Two days later, a mortar round fell on the U.S. compound, killing one U.S. soldier, and injuring another twelve.
Mogadishu was subsequently run by competing warlords until 2006, when Islamists and businessmen formed a successful coalition government, which came to be known as the Islamic Courts Union (ICU). The ICU seized control of the entire country, except for the town of Baidoa, which was held by the Transitional Federal Government, the internationally recognized government of Somalia. Later that same year, the Ethiopian military ousted the ICU and restored the internationally-recognized government, which had long remained in exile in Kenya, with Baidoa being its only Somali foothold.
Mogadishu was the scene of bitter warfare and devastation caused by fighting between Ethiopian and Somali government troops, and Islamist guerrillas. Fighting escalated in March–April 2007, November 2007 and April 2008 with hundreds of civilian casualties. In October 2008, the BBC reported that the city had been "abandoned by at least half of its residents", and that there were "street after ruined street of bombed-out buildings in the center of Mogadishu".
As of 2008, a 2,700-strong African Union peacekeeping force is attempting to bring stability and security to the city, as well as providing medical aid to the population.
Since May 8, 2009, there has been an increase in violence reportedly leading to the displacement of more than 165,000 of the inhabitants. The violence has culminated in several suicide bomb attacks, normally rare occurrences in Somalia. The attacks have claimed many lives, amongst them Mohamed Hussein Addow, a legislative politician and the third high-profile public killing in as many days throughout the country.
During the holy month of Ramadan in 2010, Al-Shabaab militants launched one of their largest offensives ever. The Transitional Federal Government's troops and their AMISOM allies managed to successfully fend off the attack, marking the turning of the tide for battle of control over the city. A new government was subsequently elected in November of the year, which, in its first 50 days in power, has managed to make steady gains in territory. As of May 2011, the TFG and its AMISOM allies have managed to secure control of 60% of Mogadishu, where 80% of the city's population now lives. Out of the city's 16 districts, 7 are under government control, while 3 are controlled by the Islamist militants; the remaining 6 districts are contested. With almost a thousand newly-trained government troops on the way, set to be augmented by an additional 4000 AMISOM soldiers, the pace of territorial gains is expected to greatly accelerate.
Mogadishu traditionally served as a commercial and financial center. The economy has recovered somewhat from the civil unrest, faring relatively better than other Somali cities, although the Somali Civil War still presents many problems. Hotels and other businesses have hired private security militias to provide protection and ensure the normal course of business.
Principal industries include food and beverage processing and textiles, especially cotton ginning. The main market offers goods from food to electronic gadgets.
Hormuud Telecom, the largest telecommunications company in southern and central Somalia, has its headquarters in Mogadishu. Telcom is another telecommunications service provider based in the city.
The Transitional Federal Government (TFG) is the current internationally recognized federal government of Somalia. Based in Mogadishu, it constitutes the executive branch of government.
In November 2010, a new technocratic government was elected to office. In its first 50 days in office, the 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.
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.
The Transitional Federal Government continues to reach out to both Somali and international stakeholders to help grow the administrative capacity of the Transitional Federal Institutions and to work toward eventual national elections in 2011, when the interim government's mandate expires.
Despite the civil unrest, Mogadishu counts several institutions of higher learning. Mogadishu University (MU) is a non-governmental university that is governed by a Board of Trustees and a University Council. It is the brainchild of a number of professors from the Somali National University as well as other Somali intellectuals who sought to find ways to provide post-secondary education in the wake of the civil war. Financed by the Islamic Development Bank in Jeddah, Saudi Arabia, as well as other donor institutions, the university counts hundreds of young Somali graduates from its seven faculties, some of whom continue on to pursue Master's degrees abroad thanks to a scholarship program. Mogadishu University has established partnerships with several other academic institutions, including the University of Aalborg in Denmark, three universities in Egypt, seven universities in Sudan, the University of Djibouti, and two universities in Yemen. It has also been scored among the 100 best universities in Africa in spite of the harsh environment, which has been hailed as a triumph for grass-roots initiatives.
The Somali National University, founded in 1954 during the "Italian Trust Administration of Somalia" (AFIS), has been closed indefinitely due to extensive damage.
Benadir University (BU) was established in 2002 with the intention of training doctors. It has since expanded into other fields.
Due to human capital shortage in the country's private sector management, the Somali Institute of Management and Administration Development (SIMAD) has given priority to the fields of business administration, information technology and accountancy.