A witnesses said the attackers were dressed in Somali military uniform.
People were seen trying to escape the violence from the upper floors of the court buildings by breaking windows and climbing out of the buildings.
It was set off as a convoy carrying Turkish aid workers passed, killing two of them.
Correspondents say Sunday’s violence is the worst seen in Mogadishu since al-Shabab was pushed out of the city by AU and Somali forces in August 2011.
Since then the Islamist group has launched regular attacks in the capital. It still controls most villages and rural areas of Somalia.
For more than 20 years Somalia has seen clan-based warlords, rival politicians and Islamist militants battling for control of the country.
Source: Midnimo Information Center
Xafiiska Wararka Midnimo, firstname.lastname@example.org email@example.com