Armed men dressed in Somali police uniforms have stormed the court complex in the capital Mogadishu killing a number of people, before a gun battle erupted with security forces besieging the compound.
Hours after the attack at the court on Sunday, a large blast hit an area on the road to the Mogadishu airport, residents said.
Somali officials told Al Jazeera that nine fighters dressed in police uniforms attacked the court complex killed ten national security officers outside the court complex before entering.
Once inside the court, the fighters killed at least three people, including two lawyers and a spokesperson of the court.
An al-Shabab spokesperson claimed responsibility for the attacks, telling Al Jazeera that as a state institution the court complex was a "legitimate target".
Hours later, a car bomb exploded at a building housing Somali intelligence along the road to the airport as Turkish and African Union (AU) vehicles were passing, police and witnesses said.
Government forces then opened fire and blocked the road.
"The car bomb exploded near the gate of a building housing the Somali security. AU and Turkish cars were also passing there. We are still investigating the target and casualties," Qadar Ali, a police officer told the Reuters news agency.
A Turkish official who spoke on condition of anonymity told Reuters that one of its Red Crescent vehicles was passing at the time of the explosion. A Somali driver was killed and three Turkish passengers were wounded, the official said.
In total, Somali officials said more than 30 people were killed on Sunday, including the nine fighters who stormed the court.
'Sign of desperation'
In control of much of the capital Mogadishu between 2009 and 2011, al-Shabab has been forced out of most major cities in central and southern Somalia by African Union peacekeepers.
But the al-Qaeda-linked fighters have claimed responsibility for a number of suicide bombings in Mogadishu this year.
Last month at least 10 people were killed by a car bomb claimed by al-Shabab in Mogadishu, police said.
Somali President Hassan Sheikh Mohamud called Sunday's attacks a “sign of desperation by the terrorists, who’ve lost all their stronghold and are in complete decline right across Somalia.”
"Somalia is moving and will keep moving forward and will not be prevented to achieve the ultimate noble goal, a peaceful and stable Somalia, by a few desperate terrorists," Mohamud said in a statement.
Al Jazeera’s Peter Greste reporting from neighbouring Kenya said it’s clear that the Somali capital isn’t “as safe as the government would like to believe.”
“But there is a certain degree of stability and security that we haven’t seen there for two years, and I know that the government is very keen to try and make sure that it stays that way.”