It’s not one Somali civil war, there have been several. The Civil War is an euphemism for the state of affairs of state collapse. There are 3 distinct and separate civil wars and 3 different “warring states” periods in Somali recent history starting in the early 1980s.
There is the original civil war, which was a revolutionary series of rebellions against the Siyaad Barre government, which began as a northern rebellion and ended with a southern rebel unified army (the Somali Liberation Army) and succeeded in overthrowing Siyaad Barre.
After Somalia’s defeat in the Ogaden War, Ethiopia and South Yemen began harassing the Siyaad Barre government by funding and arming the Somali Salvation Democratic Front or SSDF, made up of Majerteen Harti clan rebels. The SSDF’s stated goal was the re-establishment of democratic government in Somalia, though after capturing one border down, Ethiopia announced the annexation of said border town, which embarrassed the SSDF and caused them to lose support. In 1984, Ethiopia and Somalia agreed on a peace agreement and Ethiopia arrested the SSDF leadership, however many of the SSDF members remained free and in 1988, with the civil war raging, the SSDF re-entered the war on the side of the other rebel groups and helped to overthrow the Siyaad Barre government.
Somalia had been a Soviet client state prior to 1977, but when Somalia attacked Ethiopia in the Ogaden War, the Soviet Union sided with newly-communist Ethiopia, so Somalia switched sides and became an American client state, hoping American support would win them the war, which it didn’t as the Carter administration agreed with the Soviets on imposing a status quo peace. With American clientage came oil exploration in northern Somalia and soon enough Conoco struck oil in northern Somalia, in the Nugaal valley. This triggered a sudden and dramatic interest from the local northern clans in asserting sovereignty over their territories and getting rid of the Siyaad Barre regime, and the Somali National Movement, an Isaaq clan based rebel group, formed in London in 1981. The Siyaad Barre government, also suddenly immensely interested in asserting control over northern Somalia, arrested thousands of Isaaq and sent the army to the north. This sparked a war between the Isaaq clan and the central government which escalated to genocidal war, where a plan was put in place to exterminate the Isaaq and resettle northern Somalia with Somalis from Ethiopia. This plan was never able to be executed as the civil war had reached every corner of Somalia by 1988.
The Hawiye is one of the largest and most powerful clan families in Somalia, but were second class citizens under the Siyaad Barre government, despite one of the key figures in the dictatorship’s Revolutonary Council being Hawiye, General Mohamed Farah Aidiid. Hawiye lived mostly in the center of the country surrounding the capital city Mogadishu and were overrepresented in the army. When Somalia was defeated in the Ogaden War there was an attempted coup against Siyaad Barre in 1978 which failed. While Mohamed Farah Aidiid was not involved in the coup, Siyaad Barre had grown paranoid and decided to get rid of him by sending Aidiid to India as the Somali ambassador. In 1986 Siyaad Barre was injured in a car accident and there was speculation he might die as he was treated in a hospital in Saudi Arabia. In Rome a group of Hawiye dissidents formed the United Somali Congress or USC a month later and began a rebellion against Siyaad Barre in the middle of the country. Mohamed Farah Aidiid left India to lead and organize the disparate rebel groups into the Somali Liberation Army, including other southern clans into the SLA. Fighting peaked in 1988 with battles raging throughout the country, and by 1990 Siyaad Barre had lost control of all of Somalia except for Mogadishu itself. In 1991 after months of planning the SLA stormed Mogadishu and Siyaad Barre fled the country.
After Barre was overthrown his forces (at that point whittled down to pretty much just his own clan, the Marexan) became rebels themselves, the Somali National Front. The SNF fought to restore Siyaad Barre’s rule until the old dicator finally died in exile in Nigeria in 1995. With the regime overthrown, the groups which had united to topple Siyaad Barre began immediately fighting amongst themselves. The same day Siyaad Barre was deposed, the USC split and started fighting itself between Mudulood and Habar Gidir factions. The SPM split immediately and started fighting between Ogaden and Harti factions. The SSDF didn’t suffer any splits and internal war which helped them get a head start on other groups, though this is primary due to the fact that the SSDF were all from the same clan. The SNM in the north, following an attempted genocide from the Somali government and expecting to become a new Dubai with oil riches, declared independence as the Republic of Somaliland, and then had their own civil war inside another civil war as the non-Isaaq clans inside their proposed borders rebelled against Isaaq rule, a struggle which persists to the present day.
With all the internal chaos, the big groups signed a peace accord in 1992 which technically speaking ended the war, but fighting continued. Mohamed Farah Aidiid, then the leader of the Habar Gidir faction of the USC, tried to resolve the chaos by force and attacked all the groups that refused to acknowledge his leadership, which was pretty much everyone who wasn’t Habar Gidir. His battles with various armies in southern Somalia caused hardships for the local and uninvolved people who lived in the contested highlands of Bay and Bakool who ended up making another rebel group the Rahanweyn Resistance Army who fought against all the groups occupying their lands. When Aidiid died in battle in 1996 the fighting eventually died down and the rebel groups devolved into warlord kingdoms of smaller and smaller size, each warlord commanding a particular subclan or even subsubclan, controlling some neighborhood of Mogadishu and a few towns somewhere else.
The SSDF, which had managed to avoid this fragmentation due to their early unity, formed Puntland in 1998. The peace accords in 1999 made this the legal state of affairs and these warlords were made parliamentarians in a new “Transitional National Government”. Small clans without their own warlord were treated like dirt and most people were abused, the warlord armies extorted money from people, looted what they wanted and acted like they owned the place, which legally they did. In 2000 the new government took power, led by former Siyaad Barre officials who behind the scenes worked to undermine the power of the warlords by encouraging Islamist groups to establish islamic courts and militias as an alternative to warlord power.
The TNG wanted to form a unified Somali state, to put humpty dumpty back together again. The warlords (to preserve their kingdoms) and Puntland (to keep their autonomy) undermined the TNG and formed a unified front to oppose it, the “Somalia Reconciliation and Restoration Council”. Another group of Hawiye and Marehan warlords along with islamist groups decided to support the new government and work towards national unification and formed an alliance to support the TNG, the Jubba Valley Alliance. The SRRC and the JVA then started a new civil war in the south, which the JVA won, kicking the SRRC out of southern Somalia. For various reasons, Somalia’s neighbors decided a fragmented and weak Somalia was in their interests and so they orchestrated a political victory for the SRRC, despite their military defeat, and the TNG mandate was not renewed in 2004.
The SRRC then formed a new government for the country, one based on fragmentation and clan kingdoms, the Transitional Federal Government. The president of Puntland, the ostensible leader of the SRRC, was made president of the TFG. Barre Hiraale of the JVA decided to support the TFG which alienated his Islamist allies in the JVA, and the Islamists, who had been armed and grown under the TNG, started fighting with the TFG. The Islamists formed a unified military command in 2005 under the Union of Islamic Courts, a union of islamic court militias from Mogadishu and throughout JVA territory. To cash in on anti-terrorism funding from the post-9/11 United States government the SRRC rebranded themselves the “Alliance for the Restoration of Peace and Counter-Terrorism”, which worked wonders as US aid and arms poured into the arms of the warlords, most of which would be captured by the UIC shortly thereafter. The UIC defeated the TFG warlords in Mogadishu and rapidly expanded, conquering most of Somalia and had laid siege to the TFG capital Baidoa on 25 December 2006. This is when Somalias neighbors, again alarmed by a unified Somali state, again intervened, and Ethiopia invaded and defeated the UIC, with American air support and heavy weapons.
This started the third civil war. While the Ethiopian army succeeded in taking Mogadishu and installed the TFG there on the back of Ethiopian tanks, the UIC forces went to ground and the Ethiopian army got bogged down fighting resistance forces in Mogadishu. The UIC fragmented after their defeat but the conflict continues to this day.