Al-Shabab wants its hard-line brand of Sharia introduced all over the country
Somali Islamist rebel group al-Shabab has confirmed for the first time that its fighters are aligned with al-Qaeda's global militant campaign.
The group said in a statement that the "jihad of Horn of Africa must be combined with the international jihad led by the al-Qaeda network".
Meanwhile, several people have died in fighting in Mogadishu after government troops shelled militant positions.
Islamist insurgents control much of southern and central Somalia.
The government, which is backed by the UN and African Union, holds sway only in a small part of Mogadishu.
Despite repeated accusations by the US that al-Shabab is linked to al-Qaeda, the group denied the connection in a recent interview with the BBC.
The BBC Somali service's Mohamed Mohamed says it is the first time the group has officially confirmed its fight is linked to al-Qaeda.
'Financer of terrorism'
The group's statement also announced that its militants had joined forces with a smaller insurgent group called Kamboni.
The group, based in the southern town of Ras Kamboni, was previously allied to Hizbul-Islam - another militant group fighting the government.
Kamboni is led by Hassan Turki, a militant the US accuses of being a "financer of terrorism".
Al-Shabab said it was trying to unite all Islamist forces to create a Muslim state under its hard-line interpretation of Sharia law.
The group, which controls swathes of Somalia, has carried out public beheadings and stonings.
Meanwhile in Mogadishu reports said at least eight civilians were killed in fighting overnight.
"Our team collected eight bodies of civilians who were killed in the shelling and 55 others who were injured, some of them seriously," health official Ali Musa told the AFP news agency.
Militants had launched an artillery attack on the presidential compound, and government and African Union forces responded with several mortar shells.
AFP quoted an unnamed police official accusing the rebels of hiding in civilian areas and using "human shields".
Somalia has been wracked by violence for much of the past 20 years. It has not had a functioning central government since 1991.